我无法匹配下面代码的括号,其余的条件工作正常。
if (!preg_match(!preg_match("/^[a-zA-Z0-9 -,._\/\))]{10,50}$/",$phone)))
{
$_SESSION['nameErr'] .= "<li>Phone should contain only letters, Numbers and special Characters(Collan(:), Hyphen(-), Comma(,), Underscore(_), Slash(/),Parenthesis() are allowed) and Min limit 10 Characters Max limit is 50 Characters.</li>";
$errors = 1;
}
示例:
011-45538691 / 92/93(从早上7:30到下午2:00)
答案 0 :(得分:1)
您可以使用:
if (!preg_match('%^[\w:,/()-]{10,50}$%', $phone)) {
$_SESSION['nameErr'] .= "<li>Phone should contain only letters, Numbers and special Characters(Collan(:), Hyphen(-), Comma(,), Underscore(_), Slash(/),Parenthesis() are allowed) and Min limit 10 Characters Max limit is 50 Characters.</li>";
$errors = 1;
}