检查特定格式的正则表达式
regular expression to check particular format
如何创建一个正则表达式来检查字符串是否包含数字 ,+ , (,) 和空格
if (preg_match('/[0-9]/', $val)){
echo 'Secure enough';
}
正则表达式如何
/^[-0-9+)( ]+$/
例子
preg_match("/^[-0-9+)( ]+$/", "1234");
=> True
preg_match("/^[-0-9+)( ]+$/", "12(34)");
=> True
preg_match("/^[-0-9+)( ]+$/", "+1234");
=> True
preg_match("/^[-0-9+)( ]+$/", "1234 123");
=> True
preg_match("/^[-0-9+)( ]+$/", "1234123");
=> True
preg_match("/^[-0-9+)( ]+$/", "12341adf");
=> False
如何创建一个正则表达式来检查字符串是否包含数字 ,+ , (,) 和空格
if (preg_match('/[0-9]/', $val)){
echo 'Secure enough';
}
正则表达式如何
/^[-0-9+)( ]+$/
例子
preg_match("/^[-0-9+)( ]+$/", "1234");
=> True
preg_match("/^[-0-9+)( ]+$/", "12(34)");
=> True
preg_match("/^[-0-9+)( ]+$/", "+1234");
=> True
preg_match("/^[-0-9+)( ]+$/", "1234 123");
=> True
preg_match("/^[-0-9+)( ]+$/", "1234123");
=> True
preg_match("/^[-0-9+)( ]+$/", "12341adf");
=> False