我想验证手机号码字段。我根据自己的需求尝试了许多正则表达式
匹配案例
我需要根据我的匹配情况使用正则表达式。
答案 0 :(得分:1)
尝试一下:
^[+]?(?:\d+|(?:\(\d+\)){3,}|\d+(?:(?: +|-)\d+){2,})$
您有一个演示here
解释:
^ # begin of line
[+]? # optinally start by +
(?: # group of possible options
\d+ | # first option: all numbers
(?:\(\d+\)){3,} | # second option: group of numbers withn parenthesis (min=3)
\d+(?:(?: +|-)\d+){2,} # third option: group of numbers separated by spaces or dash (min=3)
) # end of group of options
$ # end of line