Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8199594: Add doc describing how (?x) ignores spaces in character classes
Reviewed-by: darcy, naoto, iris, lancea, bpb
  • Loading branch information
Ian Graves committed Jul 23, 2021
1 parent 4ed548b commit a1c0a6a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/java.base/share/classes/java/util/regex/Pattern.java
Expand Up @@ -755,6 +755,14 @@
* within a group; in the latter case, flags are restored at the end of the
* group just as in Perl. </p></li>
*
* <li><p><i>Free-spacing mode</i> in Perl (called <i>comments
* mode</i> in this class) denoted by {@code (?x)} in the regular
* expression (or by the {@link Pattern#COMMENTS} flag when compiling
* the expression) will not ignore whitespace inside of character classes. In
* this class, whitespace inside of character classes must be escaped to be
* considered as part of the regular expression when in comments mode.
* </p></li>
*
* </ul>
*
*
Expand Down Expand Up @@ -816,7 +824,9 @@
* Permits whitespace and comments in pattern.
*
* <p> In this mode, whitespace is ignored, and embedded comments starting
* with {@code #} are ignored until the end of a line.
* with {@code #} are ignored until the end of a line. Comments mode ignores
* whitespace within a character class contained in a pattern string. Such
* whitespace must be escaped in order to be considered significant. </p>
*
* <p> Comments mode can also be enabled via the embedded flag
* expression&nbsp;{@code (?x)}.
Expand Down

1 comment on commit a1c0a6a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.