正则表达式分组捕获,贪婪匹配,反向引用,非捕获组,零宽度断言
/** 分组 */
String email = "[email protected]";
Pattern p = compile("(\\w+)[@]{1}(\\w+[.]\\w+)");
Matcher m = p.matcher(email);
if (m.find()) {
for (int i = 0; i <= m.groupCount(); i++) {
System.out.println(String.format("分组:%d,捕获:%s",i,m.group(i))
原创
2020-07-04 04:01:59 ·
361 阅读 ·
0 评论