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

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

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 14
    • core-libs
    • None
    • minimal
    • No compatibility impact; spec is updated to match the implementation.
    • Java API
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: