package 排序相关;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ArraySort {
public static void main(String[] args) {
/**
* m.find()没调用一次,游标加一
* m.groupcount()得到的是当前m.find()得到的当前组的组数,本例是两个,即([a-z]+)和(\d+)")两个
*/
Pattern p=Pattern.compile("([a-z]+)(\d+)");//m.groupcount()=2
// Pattern p=Pattern.compile("([a-z]+)(\d+)(\d+)"); //m.groupcount()三个
Matcher m=p.matcher("sasa678aaa8089aaa5768");
// System.out.println(m.find()); ///匹配aaa2223
System.out.println(m.groupCount()); //返回0,因为没有
while (m.find()) {
System.out.println(m.start());
// System.out.println(m.start(2));
System.out.println(m.end());
// System.out.println(m.end(2));
System.out.println(m.group());
// System.out.println(m.group(2));
}
}
输出:
2
0
7
sasa678
7
14
aaa8089
14
21
aaa5768