I'm trying to use a regex to test if a string matches one of a given set of other strings. I'm having trouble finding a regex method that doesn't have some holes in it. For example:
I want to know if $var contains either abc, def, or ghi. Nothing but those 3 strings should match. I've tried $var =~ /abc|def|ghi/ but a string such as abdefhi is a false positive. I've also tried /(abc|def|ghi)/ and /(abc)|(def)|(ghi)/ but the aforementioned abdefhi matches all of those.
Does anyone have a solution to this? Should I even be using a regex to test something like this in the first place?
Thanks everyone!
In reply to regex matching specific strings. by nafion112
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |