how to write regular expression to validate a string using regex in C#
        Posted  
        
            by 
                Charu
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Charu
        
        
        
        Published on 2012-12-06T10:39:17Z
        Indexed on 
            2012/12/06
            11:05 UTC
        
        
        Read the original article
        Hit count: 260
        
c#
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
© Stack Overflow or respective owner