[英]Regex for phone number in international format
I need to write a regex that will match only this formats 我需要编写一个仅与这种格式匹配的正则表达式
+420 000 000 000
+420000000000
420 000 000 000
420000000000
It can't match any az character in any part of string, just numbers, white space and "+" on the beginning. 它不能与字符串的任何部分中的任何az字符匹配,只能与数字,空格和开头的“ +”匹配。
This regex should work for you: 此正则表达式应为您工作:
$mobileNumber = "0905 222 222";
if ( preg_match("/^(\+?)([0-9] ?){9,20}$/", $mobileNumber) )
echo "matches!";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.