Home > Mobile >  I need a REGEX for one of 3 EXACT ALPHA Characters followed by 9 digits
I need a REGEX for one of 3 EXACT ALPHA Characters followed by 9 digits

Time:12-22

This will be quick.

I need a pattern for either: XC123456789 or SS123456789

This is what I have and doesn't pass muster on the Online Regex checker

/^[SXC]{2}\d[0-9]{11}$/

Thank you

CodePudding user response:

If XC and SS are the only two possible combinations then you could do something along the lines of:

/^(SS|XC)\d{9}$/

This pattern matches either SS or XC followed by 9 digits.

CodePudding user response:

You were close:

^[SXC]{2}[0-9]{9}$

This will catch two of any character inside [SXC] in any order followed by any nine digit between 0-9.

  • Related