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

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Imported:
                Indexed: