[英]Regex for a string used for save a telephone number
I have a question. 我有个问题。 How should look a regex for the following words: +23456745678 or +29845281058, (with comma) I tried but no result:
我应该如何看待以下单词的正则表达式:+23456745678或+29845281058,(带逗号),我试过但没有结果:
if (!preg_match('#^\+[0-9]{11}$#',$string)) {
return ("Msisdn $string is incorrect!");
break;
}
Always I get this error. 总是我得到这个错误。 Please help me.
请帮我。 Thx in advance
提前Thx
The pattern should be: 该模式应为:
'/\+[0-9]{11},?/'
The ^ in the beginning and $ at the end stand for beginning and end of line, which I am not sure if you really want there (my guess is not). 开头的^和结尾的$代表行的开始和结尾,我不确定您是否真的要在那里(我的猜测不是)。
Test it here: http://www.phpliveregex.com/p/78v 在这里进行测试: http : //www.phpliveregex.com/p/78v
Another option is to use \\d for digit 另一种选择是使用\\ d作为数字
'/\+\d{11},?/'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.