Don't forget to call Matcher#find()
matcher.find();
and check the result before you call group()
.
From the javadoc
Attempts to find the next subsequence of the input sequence that matches the pattern.
This method starts at the beginning of this matcher's region, or, if a previous invocation of the method was successful and the matcher has not since been reset, at the first character not matched by the previous match.
If the match succeeds then more information can be obtained via the start, end, and group methods.