Reputation: 963
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?
Upvotes: 1
Views: 222
Reputation: 96477
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}$
Upvotes: 1
Reputation: 8633
You could use something like this:
[0-68-F][0-F] || 7[0-CF]
(the ||
might not work, depending on where you're using this regex. You didn't specify that in your question)
Upvotes: 0