Regular expression to match phone numbers with country codes

前端 未结 5 1911
慢半拍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 07:00

    In the javascript, you have escaped all the brackets. Do you want them to behave as capturing groups, or do you want to match actual brackets in the string?

    Also use test instead of search. test returns true or false, not a number.

提交回复
热议问题