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

Popular posts from this blog

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -