Hi Sherman,
Looks okay in general. A couple of comments:
Have you considered providing a method to map from group name to its
group index? Would that be useful?
group(String) can simply return group(getMatchedGroupIndex(name)) rather
than duplicating the implementation. Similarly for start(String) and
end(String). Is the performance overhead due to the extra check for
(first < 0) and (group < 0 || group > groupCount()) the concern? I
btw, start(int) and end(int) are missing the check if (group < 0).
Nit: <tt>-1</tt> can be replaced with {@code -1}.
Mandy
On 4/29/13 1:56 PM, Xueming Shen wrote:
Hi,
The regex named capturing group support was added into jdk7 [1].
Matcher.group(gname) is the only direct access method we added back then
to access the matched result. The proposed change here is to add a
pair of
accessing/convenient method Matcher.start/end(gname) to access the
start/end
offset info of the matched result, to match the corresponding
start/end/group
(int index) access methods.
http://cr.openjdk.java.net/~sherman/8013252/webrev
Thanks!
-Sherman
[1] http://cr.openjdk.java.net/~sherman/6350801/webrev.02/