This content has been marked as final. Show 2 replies
taoqian wrote:Anyone has suggestion to make it work?I'm at a loss as to what you expect the members of this forum to do. The Matcher class does not have the two methods you desire and you already have a work-around in that you can use the numeric group id. Now you could raise a bug report suggesting a change but at best this is likely to take years to be implemented.
Though I can't really see the advantage and would seem to go against the spirit of using group names, if you absolutely need to use the name of a group then you could create a map between a group name and it's index.
@sabre150, you are right that I am looking for extra methods in the Matcher class.
The reason is that there is no direct map between the named-group and its numeric group id in the current version, and it is difficult to create the map between these two.
In my sample,
System.out.println(matcher.group("AString")) will display "aaa", but it is impossible to know it is the "aaa" at the beginning of the match string or the "aaa" at the end of the match string.
Thanks for you comments. I will take you advice to submit a bug report.