rito1
asked on
Regular expression match words - ignores OR
Hi All,
In C# I have the following variable that tests for the following matches... ' not ',' and ',' or '.
This seems to work fine when locating matches for ' not ' and ' and ' but it doesn't work when locating the keyword ' or '.
Can anyone see what I am doing wrong?
Many thanks,
Rich
In C# I have the following variable that tests for the following matches... ' not ',' and ',' or '.
This seems to work fine when locating matches for ' not ' and ' and ' but it doesn't work when locating the keyword ' or '.
Can anyone see what I am doing wrong?
Match matchBoolOperators = Regex.Match(strSearchTerm.ToLower(), @"[ not ][ and ][ or ]");
Many thanks,
Rich
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm not a C# guy and use PCRE mostly. There are differences between regex engines. That's good you found a solution.
There's a nice comparison of features between the two (and others) on this page: http://www.regular-expressions.info/refflavors.html
ASKER
That didn't seem to work in my C#... I am starting to understand there their a different implementation of regexp for different languages... this seemed to work fine:
Open in new window