Re: Regular Expressions
| From: | Matt Palermo | Date: | Tue, 06 Apr 2004 06:51:42 +0000 |
| Subject: | Re: Regular Expressions | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-182440@lists.php.net to get a copy of this message | ||
What exactly does this do:
/< (?<=p|br) [^>]+ >/x
It may work, I just want to understand what it's looking for.
Thanks,
Matt
"Curt Zirzow" <czirzow@dotgeek.org> wrote in message
news:20040405052223.GB79839@bagend.shire...
> * Thus wrote Matt Palermo (webmaster@sweetphp.com):
> > I have a page where I am stripping the html tags down. Basically, it
will
> > allow certain tags, but still strips out ALL attributs of the tag, so it
> > works something like this:
> >
> > $allowed_tags = "<p><br><strong><b><i><u>";
> > // State which tags are allowed
> > $info = strip_tags($info, $allowed_tags);
> > // Strip all unwanted tags out
> > $allowed_tags = "p|br|strong|b|i|u";
> > // Convert tags for regular expression
> > $info = preg_replace("/<(?!".$allowed_tags.")[^>]*>/",
> > '<\1>', $info);
//
> > Strip out all attributes from allowed tags
>
> You might wont to try a look behind assertion:
> /< (?<=p|br) [^>]+ >/x
>
>
> Curt
> --
> "I used to think I was indecisive, but now I'm not so sure."