|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-03-17 09:24 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 16:00:01 2025 UTC |
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]