How check string if he contains at least 1 number or 1 letter?
How can I ensure a string contains at least 1 number 开发者_运维技巧or 1 letter?
Thanks.
$valid = preg_match('/[\pL\pN]/U', $str);
$strs = array(
'привет', // TRUE
'hello', // TRUE
'42', // TRUE
'%' // FALSE
);
Check it.
$contains = preg_match('~[\da-z]~i', $str)
精彩评论