Re: Regular expressions
| From: | jem777 | Date: | Tue, 12 Apr 2005 13:41:52 +0000 |
| Subject: | Re: Regular expressions | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-212912@lists.php.net to get a copy of this message | ||
ok for this 2:
$body = preg_replace('|\[\s*quote\s*\]|', '[quote]', $body);
$body = preg_replace('|\[\s*/\s*quote\s*\]|', '[/quote]', $body);
but have these next instructions the same result?
$body = eregi_replace("\[ *quote *\]", "[quote]", $body);
$body = eregi_replace("\[ */ *quote *\]", "[/quote]", $body);
"Jason Wong" <php-general@gremlins.biz> wrote in message
news:200504121847.03640.php-general@gremlins.biz...
> On Tuesday 12 April 2005 18:30, jem777 wrote:
> > Php docs are quite messy about what works with what function...
> > This is my problem; I want to strip out spaces from my tags:
> >
> > $word = "[ / quote ]";
> > $word = eregi_replace("[[[:blank:]]*quote[[:blank:]]*]", "[quote]",
> > $word); $word =
> > eregi_replace("[[[:blank:]]*\/[[:blank:]]*quote[[:blank:]]*]",
> > "[/quote]", $word);
> >
> > I would expect the result to be: [/quote] but it is [ /[quote].
> > It seems the first replace actually do the replace, but the how does it
> > match the slash "/" ???
>
> preg_replace('|\[\s*/\s*quote\s*]|', '[/quote]', $word);
>
> You might want to spice it up with some ungreedy modifiers.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> New Year Resolution: Ignore top posted posts