PHP RegEx提取电话号码 [英] PHP RegEx to Extract Phone No

查看:144
本文介绍了PHP RegEx提取电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bid=
id=3D46799862
03005134012
 +92-345-540700(8)
(00996)-345.(123)/4567 
 bidid=3D46799862). +966 235 123456/7
    * Need to make a payment?  You can do it here (https://www.elance.com/p=+92 123 4567891
hp/project/main/projectInvoices.php?bidid=3D46799862).
    /receivingpmbmessages.html).
<a href=3D"http://help.elance.com/entries/20992337-valign=3D"bottom" style=3D"font-s=
ize:10px; color:#817f80;padding:0px;margin:0px;">1-877-435-2623 | Mon-Fri 8=

http://rubular.com/r/U0YZQ0GlbZ 进行测试

RegEx (\d | \ +)(\ + | \d | \(| \)| - | | \。){7,} \\ \\ b

预期比赛:

Testing at http://rubular.com/r/U0YZQ0GlbZ
RegEx (\d|\+)(\+|\d|\(|\)|-| |\.){7,}\b
Expected matches :


  1. 03005134012

  2. (123)/ 4567
  3. +966 235 123456 / 7

  4. +92 123 4567891

  5. 1-877-435-2623

  1. 03005134012
  2. +92-345-540700(8)
  3. (00996)-345.(123)/4567
  4. +966 235 123456/7
  5. +92 123 4567891
  6. 1-877-435-2623

不正确的比赛:


  1. 匹配 46799862 忽略完整的单词是 3D46799862

  2. 匹配 + 92-345-540700(8 它应该匹配 + 92-345-540700(8)

  3. 匹配 00996)-345 (123 ,但应符合(00996)-345。(123)/ 4567

  4. 46799862)。+966 235 123456 b应该匹配 +966 235 123456/7

  5. 匹配 20992337 - 但是它应该被忽略,因为它的 / 20992337-valign =

  1. matching 46799862 but should be ignore beacause complete word is 3D46799862
  2. matching +92-345-540700(8 and it should match +92-345-540700(8)
  3. matching 00996)-345.(123 but it should match (00996)-345.(123)/4567
  4. matching 46799862). +966 235 123456 but it should match +966 235 123456/7
  5. Matching 20992337- but it should be ignored because its /20992337-valign=


推荐答案

(\d|\+|\()(\+|\d|\(|\)|-| |\/){7,}(\d|\))+\b  

这更准确...

这篇关于PHP RegEx提取电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆