MyEarth Posted November 26, 2015 Share Posted November 26, 2015 HelloI need to use RegExp for check if a word match of a list of other words. Example $myvar = Apple, accepted word are Apple, Banana, Mango so match = 1. Accurate, example not accept Apples or Apple ABC, string must be equal but not case sensitive.Thanks for any help Link to comment Share on other sites More sharing options...
mikell Posted November 26, 2015 Share Posted November 26, 2015 (?i) for case insensitivity\bword\b for word boundariesNo code provided => general response Link to comment Share on other sites More sharing options...
MyEarth Posted November 26, 2015 Author Share Posted November 26, 2015 No code provided? And what kind of code do you need? I have try this way:MsgBox(0,0,StringRegExp("Apple s", "(?i)\b(Apple|Banana|Mango)\b"))Give me 1 so not work Link to comment Share on other sites More sharing options...
mikell Posted November 26, 2015 Share Posted November 26, 2015 (edited) "Apples" does not match but "Apple s" does (word found)$myvar = "Apple Bananas Mango" $test = StringRegExp($myvar, '(?i)\b(apple|banana|mango)\b', 3) If IsArray($test) Then Msgbox(0,"", UBound($test) & " matches") Edited November 26, 2015 by mikell Link to comment Share on other sites More sharing options...
MyEarth Posted November 26, 2015 Author Share Posted November 26, 2015 (edited) As i have say, the string must be equal but not case-sensitive, no other words in the string. If there are other words need to return 0 also if "partially" match like in the case of "apple s" or "apple abc" Edited November 26, 2015 by MyEarth Link to comment Share on other sites More sharing options...
mikell Posted November 26, 2015 Share Posted November 26, 2015 (edited) Ah OK, then you need anchors$myvar = "Apple" $test = StringRegExp($myvar, '(?i)^(apple|banana|mango)$') Msgbox(0,"", $test) Edited November 26, 2015 by mikell MyEarth 1 Link to comment Share on other sites More sharing options...
MyEarth Posted November 26, 2015 Author Share Posted November 26, 2015 Last seems work as i need. Thanks 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