[英]Regex to find phone number with country code from string
I currently have the following:我目前有以下内容:
preg_match_all('/\b[0-9]{3}\s*-\s*[0-9]{3}\s*-\s*[0-9]{4}\b/',$cacax,$matches);
echo '<pre>';
print_r($matches[0]);
This will output:这将 output:
[0] => 888-618-0367
instead of代替
[0] => +1 888-618-0367
I got no clue on how to make that regex expression only match +1 starting numbers and also include the number in the match.我不知道如何使该正则表达式仅匹配 +1 起始数字并且还包括匹配中的数字。
Will appreciate any help, thanks!将不胜感激任何帮助,谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.