[英]How to find dashes in regex for searching phone numbers?
I have this Regex that helps me to find a phone number in a text:我有这个正则表达式可以帮助我在文本中找到电话号码:
\+?(972|0)(\-)?0?(([23489]{1}\d{7})|[5]{1}\d{8})
I would like to find a phone number with a dashes, this Regex isn't working with dashes.我想找到一个带破折号的电话号码,这个正则表达式不适用于破折号。
I tried to modified the regex to find also phone number with dases, but without any success.我试图修改正则表达式以找到带有 dases 的电话号码,但没有任何成功。
How can i add the dashes to my Regex?如何将破折号添加到我的正则表达式中?
(1[\s-]?)?\(?(\d{3}\)?[-\s]?\d{3}[-\s]?\d{4}
This regex will match all these (and any variantion of dashes and spaces but always with the 3-3-4 (US) format):此正则表达式将匹配所有这些(以及任何破折号和空格的变体,但始终使用 3-3-4(美国)格式):
1 (123) 456 7890
1234567890
123 456 7890
123-456-7890
1-123-456-7890
1-(213)-456-7890
The regex below is more international oriented:下面的正则表达式更面向国际:
((\+|00)\d+)?[\s-]?(\(\d\))?[\d-\s]+
It will match these:它将匹配这些:
+31612345678
+31 (0)6 1234 5678
0031 (0)30 12345678
+313012345678
030-1234567
0612345678
070 1234567
But also:但是也:
123456789123456789123456789
I hope this helps you further with your question我希望这可以帮助您进一步解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.