JDK-8216391 : Release Note: Correction to negation function of RegEx character classes
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.util.regex
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Delivered
  • Submitted: 2019-01-08
  • Updated: 2020-04-27
  • Resolved: 2020-04-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
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.