Predefined zero-width assertions

Zero-width Assertion

Description

\b

Asserts a word boundary

\B

Asserts anywhere except at a word boundary

^

Asserts position only at the beginning of a line

$

Asserts position only at the end of a line

\A

Asserts position only at the beginning of a string

\z

Asserts position only at the end of a string

\Z

Asserts position only at the end of a string or before the line break at the end of a string (if present)

\G

Asserts position at the end of the previous match or at the start of the string for the very first match

Get Java 9 Regular Expressions now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.