But I have found in local test run results do not conform to the rules,
String STR="2012-06-09";
The Pattern p=Pattern.com running (" (?\ \ d {4}) - (\ \ d {2}) - (\ \ d {2}) ");
The Matcher m=p. atcher (STR);
If (m. ind ()) {
System. The out. Println (m.g roup (0));
System. The out. Println (m.g roup (1));
System. The out. Println (m.g roup (2));
System. The out. Println (m.g roup (3));
System. The out. Println (m.g roup (" year "));
}
Results:
Grouping 0:20 12-06-09
Group 1:12
Grouping 2:06
Grouping 3:09
Grouping year: 2012
According to the online said the number of rules, group 1 should be output in 06, rather than the year 2012, year should be a group 3.
Which is a big help to explain, I write wrong or there is something wrong with the rules of online?