Re: Regular Expression differences between 4.4 and 5.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ewen Cumming schreef:
Hi everybody,


...


<?php
include( 'input.inc' );

$pattern = "/<!T_([^> ]+)([^>]*)>(.*?)<!T_end\\1>|<!T_([^> ]+)([^>]*)>/si";
preg_match_all( $pattern, $string, $matches );

echo phpversion();
var_dump($matches);
?>

Input.inc contains the string that is giving the different results - its
probably to long to include so you can find it at
http://www.workingweb.nl/example/input.inc.

The results of this being run can be seen at:
PHP4 (desired result) - http://www.workingweb.nl/example/php4results
PHP5 - http://www.workingweb.nl/example/php5results

If the pattern modifier 's' is removed the regex behaves consistently again
(but this breaks other pages on our website so can't be used as a
workaround). Besides I don't see why that should make any difference.


it seem you have found a regression, submit a bug with a short repro script
(cut down the test HTML and include it in the script).
I tested with php 5.2.6, it shows the same behaviour as 5.2.0.


BUT I may have work around for you, try this regexp (replaces s modifer with m modifier):

$pattern = "/<!T_([^> ]+)([^>]*)>(.*?)<!T_end\\1>|<!T_([^> ]+)([^>]*)>/mi";


my test script was:

<?php
include( 'http://www.workingweb.nl/example/input.inc' );


// $pattern = '#(?:<!T_([^> ]+)([^>]*)>(.*?)<!T_end\\1>|<!T_([^> ]+)([^>]*)>)#mi';
$pattern = "/<!T_([^> ]+)([^>]*)>(.*?)<!T_end\\1>|<!T_([^> ]+)([^>]*)>/mi";

preg_match_all( $pattern, $string, $matches );

echo phpversion();
var_dump($matches);



Here is the version information from the PHP CLI versions I've been testing
with:
user@debian:~$ php4 -v
PHP 4.4.4-8+etch6 (cli) (built: May 16 2008 15:59:34)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
user@debian:~$ php5 -v
PHP 5.2.0-8+etch11 (cli) (built: May 10 2008 10:46:24)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

Any help on this would be very appreciated.

Thanks,
Ewen



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux