Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6609854 Regex does not match correctly for negative nested character classes
  3. JDK-8216391

Release Note: Correction to negation function of RegEx character classes

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: P4
    • Resolution: Delivered
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs

      Description

      In ```java.util.regex.Pattern``` using a character class of the form ```[^a-b[c-d]]```, the negation `^` negates the entire class, not just the first range.
      The negation operator "^" has the lowest precedence among the character class operators, intersection "&&", union, range "-" and nested class "[ ]", so it is always applied last.

      Previously, the negation was applied only to the first range or group leading to inconsistent and misunderstood matches.
      Detail and examples in the issue and http://mail.openjdk.java.net/pipermail/core-libs-dev/2011-June/006957.html.

        Attachments

          Activity

            People

            Assignee:
            rriggs Roger Riggs
            Reporter:
            rcalnan Roger Calnan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: