获取电话号码,我想正则表达式所查出持续最多12个位数号码通过忽略空格,加号(+),圆括号&破折号,如:正则表达式从字符串
Primary contact number +91 98333332343 call me on this
My number is +91-983 333 32343
2nd number +1 (983) 333 32343, call me
Another one 983-333-32343
One more +91(983)-333-32343 that's all
121 street pin code 421 728 & number is 9833636363
目前,我有一个正则表达式,这确实从字符串获取联系人号码的工作:
/* This only work for the first case not for any other
and for last one it outputs "121" */
\\+?\\(?\\d*\\)? ?\\(?\\d+\\)?\\d*([\\s./-]?\\d{2,})+
那么,什么可以在这里完成,以支持上述所有情况,总之忽略特殊字符,长度应介于10-12。
字符串:'+1( - + --- +++ 983)333 32343'匹配.... – passion
@passion:是的,它应该因为任务是*提取“继续最大12位数字长数字忽略空格,加(+),括号和短划线“*,而不是*验证*。为了验证,另一个正则表达式是必要的。如果OP更具体地提取数字格式,我可以提供更“有针对性的”正则表达式,但是这个任务是以非常广泛的方式制定的。 –