How to match the character '<' not followed by ('a' or 'em' or 'strong')?
Try this:
<(?!a|em|strong)
Although Andrew's answer is clearly superior, before, I also got it to work with [^(?:a|em|strong)]
.
You use a negative lookahead, the simplest form for which is (for this problem):
<(?!a|em|strong)
The one issue with that is that it will ignore <applet>
. A way to deal with that is by using \b
, which is a zero-width expression (meaning it captures none of the input) that matches a word to non-word or non-word to word transition. Word characters are [0-9a-zA-Z_]
. So:
<(?!(a|em|strong)\b)