note 22607 deleted from function.preg-replace by sniper

From: Date: Sun, 07 Sep 2003 22:06:27 +0000
Subject: note 22607 deleted from function.preg-replace by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55705@lists.php.net to get a copy of this message
Note Submitter: gfaronNO@SPAMintegretechpub.com ---- lonestarn8, Instead of using the limit argument, which may have other side effects, try the Perl-ish solution of adding a "?" after the matched expression. This makes the match work non-greedily. For example, in a project I'm working on, this fails to match anything: preg_replace("/(\\includegraphics[.|\s]*)$oldExt/", "\\1$newExt", $text); but this works fine for every occurrence: preg_replace("/(\\includegraphics[.|\s]*)?$oldExt/", "\\1$newExt", $text);

« previous php.notes (#55705) next »