Dear All
Is this a bug ?
I'm using look-behind assertions within preg_match()
to ignore certain combinations of patterns. E.g. from
ref. manual is: (?<!foo)bar matches "bar" but only
if it's not preceded by "foo".
Here's my test script:
----------------
$line = '$res = foobar("ddd", "dfdf");';
if (preg_match("/(?<!foo)(bar)/", $line, $matches)) {
echo "Should NOT match foobar, but found: ".$matches[1];
}
$line = '$res = $bar("ddd", "dfdf");';
if (preg_match("/(?<!\$)(bar)/", $line, $matches)) {
echo "Should NOT match \$bar, but found: ".$matches[1];
}
----------------
In the first preg_match() is correctly ignores the foobar
function name. However the second preg_match() does NOT
ignore the $bar as I expected.
I converted this to Perl and it correctly ignores both!
Is this a bug, or am I missing something ?
using PHP-4.3.10 + apache 1.3.33 + fc 1
Many thanks
Ian
--
Ian Thurlbeck http://www.stams.strath.ac.uk/
Statistics and Modelling Science, University of Strathclyde
Livingstone Tower, 26 Richmond Street, Glasgow, UK, G1 1XH
Tel: +44 (0)141 548 3667 Fax: +44 (0)141 552 2079
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php