Regex to match all HTML tags except

and

后端 未结 13 735
抹茶落季
抹茶落季 2020-11-30 06:31

I need to match and remove all tags using a regular expression in Perl. I have the following:

<\\\\??(?!p).+?>

But this still matche

13条回答
  •  执念已碎
    2020-11-30 07:00

    Assuming that this will work in PERL as it does in languages that claim to use PERL-compatible syntax:

    /<\/?[^p][^>]*>/

    EDIT:

    But that won't match a

     or  tag, unfortunately.

    This, perhaps?

    /<\/?(?!p>|p )[^>]+>/
    

    That should cover

    tags that have attributes, too.

提交回复
热议问题