How to convert a PCRE to a POSIX RE?
Posted
by David M
on Stack Overflow
See other posts from Stack Overflow
or by David M
Published on 2010-05-14T21:18:58Z
Indexed on
2010/05/15
3:14 UTC
Read the original article
Hit count: 365
This interesting question http://stackoverflow.com/questions/2837267/ concerned how to do a negative look-ahead in MySQL. The poster wanted to get the effect of
Kansas(?! State)
because MySQL doesn't implement look-ahead assertions, a number of answers came up the equivalent
Kansas($|[^ ]| ($|[^S])| S($|[^t])| St($|[^a])| Sta($|[^t])| Stat($|[^e]))
The poster pointed out that's a PITA to do for potentially lots of expressions.
Is there a script/utility/mode of PCRE (or some other package) that will convert a PCRE (if possible) to an equivalent regex that doesn't use Perl's snazzy features? I'm fully aware that some Perl-style regexes cannot be stated as an ordinary regex, so I would not expect the tool to do the impossible, of course!
© Stack Overflow or respective owner