我需要匹配的电话号码:
以 010 或 012 或 016 或 019 开头
恰好由10个数字组成
您能帮我了解如何使用 PHP 和正则表达式匹配数字吗?
最佳答案
return preg_match('/^01[0269]\\d{7}$/', $theStringToTest);
这将匹配 0、1、(0、2、6、9) 之一,然后匹配任何 7 个数字 (3+7==10)。 ^
表示字符串开始,$
表示字符串结束。
关于php - 正则表达式 : Matching phone numbers starting with NNN and having 10 numbers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2798113/