Re: PCRE Multiline modifier

From: Date: Mon, 27 Aug 2001 14:15:07 +0000
Subject: Re: PCRE Multiline modifier
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-64637@lists.php.net to get a copy of this message
I think that is the solution: <? $mem = "<pre>hello world\nI love you all!</pre>"; $re = "/<pre>(.+?)<\\/pre>/is"; preg_match_all($re, $mem, $match); var_dump($match); ?> The modifier which will work for you is 's', not 'm'. Look at the manual at : http://www.php.net/manual/en/pcre.pattern.modifiers.php This produces: array(2) { [0]=> array(1) { [0]=> string(16) "<pre>hello world" } [1]=> array(1) { [0]=> string(11) "hello world" } } In this case it's better your pattern to be : "|<pre>(.+?)</pre>|is" / was changed to |, and there is no need to escape. Andrey Hristov IcyGEN Corporation http://www.icygen.com 99% ----- Original Message ----- From: "_lallous" <elias_bachaalany@yahoo.com> To: <php-general@lists.php.net> Sent: Monday, August 27, 2001 5:43 PM Subject: [PHP] PCRE Multiline modifier > <pre> > <? > $mem = "<pre>hello world\nI love you all!</pre>"; > $re = "/<pre>(.+?)<\\/pre>/im"; > > preg_match_all($re, $mem, $match); > > var_dump($match); > ?> > </pre> > > and the output is: > array(2) { > [0]=> > array(0) { > } > [1]=> > array(0) { > } > } > > if i remove the \n in the $mem var everything works okay. > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#64637) next »