Regular Expressions 101

Community Patterns

Find all html-tags except for some

1

Regular Expression
PCRE (PHP <7.3)

/
<(?!\/*strong\W|\/*h1\W|\/*input\W|\/*b\W).*?>
/
gm

Description

Find all html-tags except for some that you want to preserve for any reason. I use this to remove all tags except those I want to keep.

Submitted by anonymous - 5 years ago