TheOne23 Posted July 17, 2023 Share Posted July 17, 2023 Hi Guys, Can you help me figure out why my test script is not working? it is showing "0" which is not match where I tried to put same value of string already. It worked when it is not in a variable format. Example: This works - StringRegExp($short_description_text_1,'(po)(?!.*\1\b)',$STR_REGEXPMATCH) This does not work - StringRegExp($short_description_text_1,$string,$STR_REGEXPMATCH) #include <MsgBoxConstants.au3> #include <StringConstants.au3> local $short_description_text_1 = "po" local $keywords_split_2 = "po" local $string = "'("& $keywords_split_2 &")(?!.*\1\b)'" ;~ MsgBox(0,"",$string) ;~ MsgBox(0,"result: ",StringRegExp($short_description_text_1, "'(" & $keywords_split_2 & ")(?!.*\1\b)'" ,$STR_REGEXPMATCH)) MsgBox(0,"result: ",StringRegExp($short_description_text_1,$string,$STR_REGEXPMATCH)) Link to comment Share on other sites More sharing options...
Andreik Posted July 17, 2023 Share Posted July 17, 2023 (edited) Your string it's stored in $short_description_text_1 and your pattern in $string. Of course it cannot find '(po)(?!.*\1\b)' in po. I suppose you want to swap these two. MsgBox(0,"result: ",StringRegExp($string, $short_description_text_1, $STR_REGEXPMATCH)) Edited July 17, 2023 by Andreik Link to comment Share on other sites More sharing options...
pixelsearch Posted July 17, 2023 Share Posted July 17, 2023 (edited) @TheOne23 the superfluous single quote delimiter seems to create the issue : ; Local $string = "'(" & $keywords_split_2 & ")(?!.*\1\b)'" Local $string = "(" & $keywords_split_2 & ")(?!.*\1\b)" Does it solve your problem ? Edited July 17, 2023 by pixelsearch TheOne23 1 Link to comment Share on other sites More sharing options...
mikell Posted July 17, 2023 Share Posted July 17, 2023 18 minutes ago, pixelsearch said: Does it solve your problem ? If used in the code in post #1, with the OP's requirements for sure it will. In this case the assertion returns true TheOne23 1 Link to comment Share on other sites More sharing options...
TheOne23 Posted August 2, 2023 Author Share Posted August 2, 2023 Hi pixelsearch and Mikell, Thank you very much on your inputs. It is now solved. 👍 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now