Regular Expression,Regex PHP -



Regular Expression,Regex PHP -

i need validade string in next format:

numbers, letters , _ minimum length 4 , max length 15 @ to the lowest degree 1 letter [a-z]

for example:

valid:

abcd abcde abc_ 01a_ a12345_bcdw1234

not valid:

abc 01a a12345_bcdw123411 _1212392034 _ a_1

i made couple tries none work.

i don't think can in 1 regex, validation of constraints on length {4,15} , "must contains letter" must done independently.

$test_inputs = array( 'abcd', 'abcde', 'abc_', '01a_', 'a12345_bcdw1234' , 'abc', '01a', 'a12345_bcdw123411', '_1212392034', '_', 'a_1' ); $res = array(); foreach($test_inputs $input) { $res[$input] = (preg_match('/^[a-z0-9_]{4,15}$/i', $input) && preg_match('/[a-z]/i', $input)); } var_dump($res);

php regex expression

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -