javascript - regex to search 8 character string for two consecutive numbers and letters afterwards -
hello new regular expressions , find myself stuck on problem.
i have 8 character string has been filtered alpha numeric string contain numbers , letters. looking find first 2 consecutive digits anywhere within string , once found make sure characters after 2 consecutive digits alpha characters a-z if doesn't match return false; far have
var str = "abc11hsb
";
var testit = /[0-9]{2}/i; var test = testit.test(str); test //true
however if have string
var str = "abc11h7b";
and run same test above should return false because after first 2 digit match every character afterwards should alpha character a-z. above string has 7 after 11; regex accounts finding 2 consecutive numbers doesn't account fact each character after first 2 digits should alpha character a-z.
hope clear
again appreciated
try regular expression: /[0-9]{2}[a-z]+$/i
Comments
Post a Comment