Re: preg_match_all question

From: Date: Fri, 16 Jan 2009 10:31:27 +0000
Subject: Re: preg_match_all question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-286492@lists.php.net to get a copy of this message
On Fri, 2009-01-16 at 09:42 +0000, Phil Ewington - iModel Ltd. wrote: > Hi All, > > Having an issue with regular expressions, never been my strong point! > > The following pattern only picks up one instance per line, if more than > one instance exists all text from first {{ to last }} is included, can > anyone point out where I am going wrong? > > preg_match_all("/\{\{lang:(.*)\}\}/", $str, $tags); You need the ungreedy modifier: preg_match_all("/\{\{lang:(.*)\}\}/U", $str, $tags); Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP

« previous php.general (#286492) next »