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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -