I need to replace list of tokens, like ORELSE, ANDALSO, =, <>. But I only need to do it, when they are alone, not in a function. So
SomeVar ANDALSO SomeOTherVar ANDALSO AnotherVar = 1234
Should be replaced with
SomeVar && SomeOTherVar && AnotherVar == 1234
.
Thats something I can do. But I need to ignore tokens that are inside some function, like
IgnoreFunction 'SomeVar=AnotherVar ANDALSO test = anotherTest
.
Or
AlsoIgnoreFunction['test=value', 'anotherTest = anotherValue']
So expression SomeVar ANDALSO SomeOTherVar ANDALSO AnotherVar = 1234 IgnoreFunction 'SomeVar=AnotherVar
Should be replaced by
SomeVar && SomeOTherVar && AnotherVar == 1234 IgnoreFunction 'SomeVar=AnotherVar
As I can match simple tokens and can match these ignore functions, I cant match tokens everywhere, except inside ignore functions.
For now I use the following regexp to match tokens:
ANDALSO|ORELSE|=|<>
And this regexp to match everything inside ignore function:
\bIgnoreFunction\b (["'])(\\?.)*?\1
But I cant to figure out the pattern to stop matching equality mark inside ignore functions.
Heres the regex I used to test it: TEST (["'])(\\?.)*?\1|(=|AND|OR)
I tested it with that expression: Request.Query TEST '[\?&]th=mm(&|$)' = = = AND OR
on this site: http://regexstorm.net/tester
And it match everything, not only =, AND, OR tokens.