如何验证英国电话号码?我从这个网站复制了答案,但这个答案只接受手机号码。我想同时接受固定电话和手机号码。可能吗?
# @reference: http://stackoverflow.com/questions/8099177/validating-uk-phone-numbers-in-php
$telephone = "01752311149"; // not ok.
$telephone = "07742055388"; // ok.
$pattern = "/^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$/";
if (!preg_match($pattern, $telephone))
{
$error = true;
$message.='<error elementid="telephone" message="invalid" />';
}
我已经尝试使用下面的这个正则表达式,但它根本不起作用,
#http://stackoverflow.com/questions/14512810/regular-expression-mobile-and-landline-number
$pattern = "/^\(0\d{1,2}\)\d{3}-\d{4}$/";