正则表达式怎么不行了????

wujiang88 2016-10-06 10:55:51
String str = "123-456-7890\\n(123)456-7890\\n(123)-456-7890\\n(123-456-7890\\n1234567890\\n123 456 7890";
Pattern pattern = Pattern.compile("(?m)^(\\()?\\d{3}(?(1)\\)|-)\\d{3}-\\d{4}$");
Matcher matcher = pattern.matcher(str);
if(matcher.find()) {
System.out.println(matcher.group());
}
...全文
289 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
代码就有问题,另外你想验证得到什么样的效果
tomorrow_C 2016-10-07
  • 打赏
  • 举报
回复
可以把想要表达的正则效果说明一下吗,

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧