Regular Expression differences between 4.4 and 5.2

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

 



Hi everybody,

I'm trying to migrate our PHP code base to PHP5. For the most part the
transition hs been smooth however I'm really stuck on a regular expression
which gives different results in 4.4 and 5.2.

I've looked through migration guides but as far as I can see nothing should
have changed in Regex handling between the versions.

I've created the following script below to test the match:

<?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.

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

[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