Monday, June 19, 2006

Why Sun puts groupCount() into java.util.regex.Matcher? Why not java.util.regex.Pattern?

As in J2SDK API, groupCount() will return the number of capturing groups in pattern. And the number of group only relates with regex, not the data which will be matched. So it should be implement in java.util.regex.Pattern.

A Sun's bug?

Update: As you can see in my StringEx, I need to create a Matcher from a Pattern with blah blah data to get the number of group in pattern.

No comments: