Q:

Exclude a pattern in RegEx

I want a RegEx to match any Hex number but 7E and 7D.
To match any Hex number I use [0-9A-F]{2}. How can I now exclude the unwandted numbers?

A:

You could use a negative look-ahead that would fail on 7E or 7D. The following pattern uses ^ and $ to match the entire string, not a partial match within a string.
^(?!7[ED])[0-9A-F]{2}$

