javascript - Regex pattern search starts with 2 letters OR 2 numbers -


i'm writing javascript function detect correct entry database before sending it. variable must start either 2 digits or 2 letters followed 2 more letters 3 digits. can make each regex work independently want in 1 statement. i've tried /^[a-z]{2}|^[0-9]{2}[a-z]{2}\d{3}$/ no luck.

 var vall = /^[a-z]{2}[a-z]{2}\d{3}$/;letter     var valj = /^[0-9]{2}[a-z]{2}\d{2}$/;digits 

you need group alternation.

/^([a-z]{2}|[0-9]{2})[a-z]{2}\d{3}$/ 

otherwise match left or right side of alternation.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -