javascript - conditional regex for letter followed by number and vice versa -
my string can 2 character long
1st character can digit or alphabet
if 1st digit, 2nd should alphabet, vice-versa
e.g: 1a, a1, h2, 6h valid 11, 12, aa, bb, bb invalid.
i came regex pattern:
\d[a-za-z]{1}|[a-za-z]\d{1} that works fine. thoughts on how rewrite conditional regex appreciated.
Comments
Post a Comment