Sign in to follow this  
Followers 0
shiv

What logic to use

3 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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")
EndIf
Edit: 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 by Malkey

Share this post


Link to post
Share on other sites

another take on the regex, grab the string if it's at a word boundary at front and rear.

StringRegExp($M,'\b' & $V & '\b')

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0