shiv Posted November 21, 2013 Posted November 21, 2013 Hi All, Let us say: $V = "5.6.7.8" $M = "current version is 5.6.7.8" One way to compare both is "current version is" & $V == $M and my test will get pass -------- But i just want to make it more generic, I do not want to concatenate "current version is" with $V. is there some other way that if i can use some regular expressions in place of "current version is" if yes please elborate how Thanks
Malkey Posted November 21, 2013 Posted November 21, 2013 (edited) Try this.Local $V = "5.6.7.8" Local $M = "current version is 5.6.7.8" ; $V in $M must be at the start of the line or have a leading space; or, ; $V in $M must be at the end of the line or have a trailing space. If StringRegExp($M, "(?m)(^|\h)" & $V & "(\h|$)") Then MsgBox(0, "Results", "Test Passed") Else MsgBox(0, "Results", "Test Failed") EndIfEdit: Removed ".|" out of StringRegExp($M, "(?m)(^|h)" & $V & "(h|.|$)"), because the trailing dot was allowing "5.6.7.8.2" to pass, which is incorrect. Edited November 21, 2013 by Malkey
gruntydatsun Posted November 21, 2013 Posted November 21, 2013 another take on the regex, grab the string if it's at a word boundary at front and rear. StringRegExp($M,'\b' & $V & '\b')
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