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

Flag (?U:...) is allowed for non-capturing groups

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      No compatibility impact; spec is updated to match the implementation.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      The specification for the class java.util.regex.Pattern needs to be updated to state that the embedded flag 'U' can be turned on or off for non-capturing groups.

      Problem

      Javadoc for the class java.util.regex.Pattern specifies that these special constructs are allowed:

      (?idmsuxU-idmsuxU) Nothing, but turns match flags i d m s u x U on - off 
      (?idmsux-idmsux:X) X, as a non-capturing group with the given flags i d m s u x on - off 

      In the second case, the flag 'U' is not listed as an allowed option. In fact, this flag is recognized by the parser and can be turned on/off for non-capturing groups.

      Solution

      The spec needs to be updated to list the flag 'U' among other options.

      Specification

      The specification will be modified in the following way:

      - * <tr><th style="vertical-align:top; font-weight:normal" id="non_capture_group_flags"><code>(?idmsux-idmsux:</code><i>X</i>{@code )}&nbsp;&nbsp;</th>
      + * <tr><th style="vertical-align:top; font-weight:normal" id="non_capture_group_flags"><code>(?idmsuxU-idmsuxU:</code><i>X</i>{@code )}&nbsp;&nbsp;</th>
        *     <td headers="matches special non_capture_group_flags"><i>X</i>, as a <a href="#cg">non-capturing group</a> with the
        *         given flags <a href="#CASE_INSENSITIVE">i</a> <a href="#UNIX_LINES">d</a>
        * <a href="#MULTILINE">m</a> <a href="#DOTALL">s</a> <a href="#UNICODE_CASE">u</a >
      - * <a href="#COMMENTS">x</a> on - off</td></tr>
      + * <a href="#COMMENTS">x</a> <a href="#UNICODE_CHARACTER_CLASS">U</a> on - off</td></tr>

      Webrev with the change: http://cr.openjdk.java.net/~igerasim/8224849/00/webrev/

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              igerasim Ivan Gerasimov
              Reporter:
              igerasim Ivan Gerasimov
              Reviewed By:
              Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: