I'm having some trouble constructing a pattern that works adequately with php's preg_* functions. when I try various patterns in external agents it seems to work fine. very bizarre.
I am writing a partial sql parsing engine for a project to port wordpress to PDO abstraction layer compatibility and one of the things I need to achieve is to remove all quoted parameters.
the problem I'm running into is with escaped content. take for example this clause
I'm looking for an array of extracts which should have
the pattern that i have working in reggy (Mac OSX regular expressions GUI) is
I'd expect this to look like so in php
but this produces rubbish results.
is the php PCRE implementation bust or am I just in a head spin (in which case an alternative solution would be much appreciated)? I'm quite prepared to believe that i've just got my head on backwards - i've had to design far too many regular expressions for this project and my brain is a-burnin...
thanks
Justin
I am writing a partial sql parsing engine for a project to port wordpress to PDO abstraction layer compatibility and one of the things I need to achieve is to remove all quoted parameters.
the problem I'm running into is with escaped content. take for example this clause
Code:
Update table set field1 = "somevalue", field2 = 'John\'s toy', field3 = "<img href=\"image.php\">"
I'm looking for an array of extracts which should have
Code:
[0] => somevalue
[1] => John\'s toy
[2] => <img href=\"image.php\">
the pattern that i have working in reggy (Mac OSX regular expressions GUI) is
Code:
[^\\]('|")(.*?)[^\\]\1
Code:
$pattern = '/[^\\\\](\'|")(.*?)[^\\\\]\\1/imx';
but this produces rubbish results.
is the php PCRE implementation bust or am I just in a head spin (in which case an alternative solution would be much appreciated)? I'm quite prepared to believe that i've just got my head on backwards - i've had to design far too many regular expressions for this project and my brain is a-burnin...
thanks
Justin