Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7032377

MatchResult and Pattern should provide a way to query names of named-capturing groups

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • None
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      http://download.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

      The new RegExp packages supports named capturing groups through Match.group(String name), which is fine. But it lacks the method to get the name of the group from within the Match(Result).

      In my case I'd like to loop through all matches and from within that match, check if there's a named capturing group associated. If so, I'd like to get the name and put the match into an Map<String groupname, String result>.

      Would be great to have this enchancements in JDK7.

      JUSTIFICATION :
      It makes the named capturing groups usefull in a lot more cases.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      MatchResult.getGroupName(); oid.
      ACTUAL -
      No function available.

      CUSTOMER SUBMITTED WORKAROUND :
      Having some manual Mapping between the group index and the name to associate.

            smarks Stuart Marks
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: