.*为贪婪模式,.*?为非贪婪模式。例如
1: String regex1="a(.*)b";
2: String regex2="a(.*?)b";
3:
4: Pattern info = Pattern.compile(regex1);
5: Matcher matcher = info.matcher("acbcbc");
6:
7: matcher.group(1);//得到cbc
8:
9: Pattern info = Pattern.compile(regex2);
10: Matcher matcher = info.matcher("acbcbc");
11:
12: matcher.group(1);//得到c
13: