Java正则表达式部分摘录
//匹配规则(正则表达式)
String[] patternStr="\\d+";
String[] inputStr;
//Parttern类编译匹配规则
Pattern p=Pattern.compile();
//Matcher类储存匹配处理后内容,通过Pattern类调用matcher()创建Matcher对象
Matcher m=p.matcher(inputStr);
Matcher常用方法
以 ([a-z]+)(\d+) 匹配 ac666ac 为例
Matcher m=p.matcher("ac666ac_");
m.find(); //匹配ac666ac
m.groupCount(); //返回2,因为有2组
m.start(1); //返回0 返回第一组匹配到的子字符串在字符串中的索引号
m.start(2); //返回3
m.end(1); //返回2 返回第一组匹配到的子字符串的最后一个字符在字符串中的索引位置.
m.end(2); //返回7
m.group(1); //返回ac,返回第一组匹配到的子字符串
m.group(2); //返回ac_,返回第二组匹配到的子字符串