php正则表达式,从html文档中提取电话号码正则表达式

Mic*_*el 1 php regex

我正在尝试从不同的html页面中提取特定信息.基本上,信息是10位数字,可能有不同的形式,如:

000-000-0000
000 - 000 - 0000
0000000000
please note that 000 - 000 - 0000000 is not a valid phone number so it should not extract the number if it contains any additional digits

我很感激任何帮助,以创建完整的正则表达式,适用于所有3种情况.到目前为止,我可以让它只适用于最后一个(最简单的一个).

Jef*_*eff 5

这将匹配您列出的所有三个示例.

(\d{3}\s*-?\s*\d{3}\s*-?\s*\d{4})
Run Code Online (Sandbox Code Playgroud)