[英]Regex pattern not identifying pattern
我正在使用正则表达式模式从字符串中提取匹配项
我的模式是:
"^(([^\\.\\-\\,a-wy-z]([\\(]?(\\+|[x])?\\d+[\\)]?)?[\\s\\.\\-\\,]?([\\(\\d[\\)]?)?[\\s\\.\\-\\,]?(\\d+[\\s\\.\\-\\,]?)+[^\\.\\-\\,a-z])|((\\+|[x])?\\d+))$"
我的字符串是
"This is the string +971 987654321 form which +91 9876543210 all the phone number +91 987 654 3210 has to be extracted +91 987 654 3210 and displayed in the +971-98-7654321 logcat and the post office box number is 233227"
但不幸的是,该模式没有从字符串中识别出任何匹配的模式。 我已经通过意图操作验证了“Check RegExp”中的表达式。 这里的模式成功识别了我在字符串中使用的所有电话号码
任何帮助表示赞赏。
假设您的电话号码中至少有10
位数字(不包括+
、空格、 -
等),这将起作用
\s+(\+[\d\s-]{10,})\s+
如果您假设,数字和单词之间不能有空格,那么您可以使用
(\+[\d\s-]{10,})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.