Re: PCRE Multiline modifier
| From: | _lallous | Date: | Tue, 28 Aug 2001 07:57:49 +0000 |
| Subject: | Re: PCRE Multiline modifier | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64738@lists.php.net to get a copy of this message | ||
Thanks!
But I still nned to escape, but only once. I mean '<\/pre>' instead of
'<\\/pre>'.
"Andrey Hristov" <ahristov@icygen.com> wrote in message
news:004401c12f02$ae5a2d30$0b01a8c0@ANDreY...
> 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
> >
> >
>