|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-02-02 17:38 UTC] cryo at tiscali dot dk
This is most likely a bug in the PCRE library. It happens with certain patterns in a no-match situation. Consider the following pattern: /AA(([^A]*A?[^A]+)+)AA/ The letter A doesn't matter. This allows the matching of 'AA' delimited strings, while still allowing single A's inside such strings. Note that /AA(.*)AA/ will not work, since it will just match the outermost enclosing of such a string. Now when matching for instance: test AAthis is a test of some text insideAA end. This works fine, and returns right away with preg_match or preg_replace alike. Also with ereg it works fine (without the / pattern delimiters of course). Now consider the similar string: test AAthis is a test of some text inside end. The delimiter at the end was removed. Now both preg_match and preg_replace time out after the maximum execution time of 30 seconds. ereg still works fine. The longer the text after the opening AA, the longer time it takes. This is long enough to never finish (within the allotted time), while shorter texts will make it finish after e.g. 20 seconds or so. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
<?php $foo = "test AAthis is a test of some text inside end."; var_dump(preg_match("/AA(([^A]*A?[^A]+)+)AA/", $foo)); ?> This just hangs.