in reply to Regex runs for too long
Still, as a general regex efficiency principle, you can rewrite /(?:.(?!foo))*/ as /.*?foo/. The regex engine won't go character-by-character; it'll be smart about it and jump from one "f" to the next until it finds an "f" followed by "oo". Or you could use /[^f]*(?:f(?!oo)[^f]*)*/, although I'd personally go with the simpler .*? approach.
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|