From: gmarik at gmail dot com Operating system: win xp PHP version: 5.1.2 PHP Bug Type: *Regular Expressions Bug description: preg_match_all(): Compilation failed
Description: ------------ Fails to compile pattern. Workaround: put laziness switch `?` right after `+` quantifier: ... +? # 1 or more times as short as possible(lazy matching) ... Reproduce code: --------------- //fetch image URLs $pattern = '~ < # open tag img # name \s # whitespace + # 1 or more times src= # image source attribute equals " # open quote ( # begin group capture [^"] # URL: everything up to quote + # 1 or more times ? # as short as possible(lazy matching) ) # end group capture " # close quote [^>] # any except > * # 0 or more times > # close tag ~xi'; //omit whitespaces, case insensitive preg_match_all($pattern, '<img src="test"/>', $matches); echo $matches[1]; Expected result: ---------------- test Actual result: -------------- PHP Warning: preg_match_all(): Compilation failed: nothing to repeat at offset [...stripped] -- Edit bug report at http://bugs.php.net/?id=36765&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36765&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36765&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36765&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36765&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36765&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36765&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36765&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36765&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36765&r=support Expected behavior: http://bugs.php.net/fix.php?id=36765&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36765&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36765&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36765&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36765&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36765&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36765&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36765&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36765&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36765&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36765&r=mysqlcfg