I need to validate a user input based on condition. i wrote a regular expression to do so, but it's failing not sure why. Can somebody point where i am making mistake?
Regex AccuracyCodeHexRegex = new Regex(@"^[PTQA]((0|8)[01234567]){2}$");
This is what i am trying to validate(If the string is a subset of these strings then it is valid):
Phh, Thh, Qhh, Ahh where 'h' is a hex digit in the set {00, 80, 01, 81, 02, 82, 03, 83, 04, 84, 05, 85, 06, 86, 07, 87}
Ex: P00 is valid P20 is not valid
P00doesn't match what you describe. You sayPhhwhere eachhis two digits (from a set), butP00isPhwherehis two digits.P00valid? It shouldn't be (ifhis00and you have twohh-P0000should be valid).