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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 14
    • None
    • core-libs

      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.

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

              Created:
              Updated:
              Resolved: