regex - JavaScript regular expression - two [a-z] followed by three [0-9] only -


i've got simple regular expression:

[a-z]{2}[0-9]{3})$/g inside following:

regform.submit(function(){   if ($.trim($('#new-usr').val()).match(/([a-z]{2}[0-9]{3})$/g)) {     alert('no');     return false;   } }); 

this correctly reading 'ab123' gives alert , 'ab1234' doesn't. however, 'abc123' still throwing alert. need it's throwing alert when it's 2 letters followed 3 numbers.

try /^[a-z]{2}[0-9]{3}$/g instead.

you need specify whole string needs matched. otherwise highlighted part matched: abc123.

(i omitted ()'s, because don't need group.)

btw, sure want [a-z] , not [a-za-z]?


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -