How would I use regex to check for a value that has two fixed uppercase letters followed by numeric values in PHP or jQuery? -


an example "su1203" or "up1234" or 2 letters followed numeric values. thanks

this can solved quite simple expression

^[a-z]{2}\d+$ 

in javascript can use test() method:

if(/^[a-z]{2}\d+$/.test(str)) 

and in php, preg_match:

if(preg_match('/^[a-z]{2}\d+$/', $str) === 1) 

i suggest learn regular expressions.

see also:


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -