正则表达式学习

教程:http://deerchao.net/tutorials/regex/regex-1.htm

在线调试:http://regexr.com/

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestPattern {
public static void main(String args[]) {

Pattern pattern = Pattern.compile("(\\w+)\\\\(\\d+)");
Matcher m=pattern.matcher("regexTest\\30");

while (m.find()) {
System.out.println(m.group()); //regexTest\30
System.out.println(m.group(1));//regexTest
System.out.println(m.group(2));//30
}
}
}

 

posted on 2016-03-31 22:12  一点一滴的水  阅读(121)  评论(0编辑  收藏  举报