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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.