Regular expression to match phone numbers with country codes

前端 未结 5 1884
慢半拍i
慢半拍i 2021-01-16 06:37

This is the regular expression I use to match phone numbers like:

00 00 00 00 00
00 00 0 00 00 00 00
+00 0 00 00 00 00

(\\d{2}\\s+\\d{2}\\s+\\d{2}\\s+\\d{2}         


        
5条回答
  •  伪装坚强ぢ
    2021-01-16 06:53

    Escaping the parenthesis turns them into literals. Try it without the escapes:

    /^(\d{2}\s+\d{2}\s+\d{2}\s+\d{2}\s+\d{2})\s+(\d{2}\s+\d{2}\s+\d\s+\d{2}\s+\d{2}\s+\d{2}\s+\d{2})\s+(\d{2}\s+\d\s+\d{2}\s+\d{2}\s+\d{2}\s+\d{2})/
    

提交回复
热议问题