how to write regular expression to validate a string using regex in C#
- by Charu
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