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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:

      Description

      Javadoc for java.util.regex.Pattern specifies that these special costructs 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.

      Below is a testcase, which demonstrates that the flag U is indeed recognized:
      ----------
      import java.util.regex.*;
      public class U {
          public static void main(String[] args) throws Throwable {
              Pattern p = Pattern.compile("(?U:\\d)");
              Matcher m = p.matcher("\uFF11");
              System.out.println(p + " " + m.matches());
          }
      }
      ----------
      Prints out:
      (?U:\d) true
      ----------

      The javadoc has to be updated accordingly.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: