Veign
02-19-2005, 05:36 PM
I was wondering how do you force a RegEx search to ignore regular expressions and just search for the exact search string..
Eaxmple:
This is a (test)..
I want to locate (test) without the RegEx engine evaluating the RegEx commands...
Any ideas - I want this to be the case for even very complex patterns
ZiDev
02-19-2005, 06:25 PM
Escape the ( and ) with \.
I'm n ot sure I understand you properly, but if you want PCRE to not use ( and ) as capture symbols, that's what you need.
Veign
02-19-2005, 07:18 PM
I know of the escape commands but this seems very tedious for more complex expressions - I would have to escape all characters. I thought there may be a simple way to force the engine to search for a string without evaluating the pattern...
error404
02-19-2005, 07:32 PM
Why not just use a plain string comparison then?...it should be much faster, and you don't have to futz with escaping metacharacters...
fastduke
02-19-2005, 08:21 PM
true if you are only looking to see if a string is contained in a string a regex is pretty much overkill.
But when you need to start remembering multiple things matched then you need the power of regex.
I would say in most my situations regex is the way to go. But hey my first lang was perl (minus cgi crap) ;)
Veign
02-20-2005, 10:50 AM
Originally posted by error404
Why not just use a plain string comparison then?...
I want to use a single interface and a single engine for the file replace feature I have....
error404
02-20-2005, 05:39 PM
You could write a simple function that escapes all metacharacters between quotation marks or something similar.
Veign
02-20-2005, 08:23 PM
Thanx...That looks like what I will have to do...