I want to limit the length of hex number to 4 OR 8. For example:
0x0001
is valid (4 hex numbers)
0x0001001F
is valid (8 hex numbers)
0x00012
is invalid (5 hex numbers)
I can validate a hex number with length of n (n is 4 or 8) by using
Regex.IsMatch("0x0001", "^0x[0-9a-fA-F][{n}$");
How to achieve this OR operation, say either 4 or 8, not from 4 to 8?