#36765 [Opn->Bgs]: preg_match_all(): Compilation failed

From: Date: Fri, 17 Mar 2006 08:24:08 +0000
Subject: #36765 [Opn->Bgs]: preg_match_all(): Compilation failed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-94454@lists.php.net to get a copy of this message
ID: 36765 Updated by: tony2001@php.net Reported By: gmarik at gmail dot com -Status: Open +Status: Bogus Bug Type: *Regular Expressions Operating System: win xp PHP Version: 5.1.2 New Comment: PHP pcre_*() functions are just wrappers for PCRELib functionality. If PCRELib fails to compile an expression - there is nothing we can do about it. Previous Comments: ------------------------------------------------------------------------ [2006-03-16 23:15:23] gmarik at gmail dot com 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 this bug report at http://bugs.php.net/?id=36765&edit=1

« previous php.bugs (#94454) next »