I'm using this regular expression to parse a string like "CALENDAR YEAR: 2012"
.Can someone suggest a better one ? And I want to use matcher.find() (CALENDAR YEAR:\\s+)?((2\\d\\d\\d))
I want to get 2012 in a group.
I can't understand why it prints null when i do this:
while (myMatcher.find()) {
System.out.println(myMatcher.group(1));
System.out.println(myMatcher.group(2));
}
CALENDAR YEAR:
2012
null
null
EDIT: How will I change the expression if the code is using matches and i Still want to parse the year out of the string?