O'Reilly logo

Java 9 Regular Expressions by Anubhava Srivastava

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Zero-width assertions

Zero-width or zero-length assertion in regular expressions means that there is a zero-length match that does not change the current position of the pointer in the input string. These assertions do not consume characters in the string but only assert whether a match is possible or not, giving us a binary true or false match result. Although many zero-width assertions are denoted inside parentheses, like groups, we will soon see that they do not capture any text. Zero-width assertions have no real meaning in back-references or in replacements.

We have already discussed a few zero-width assertions in the previous chapters, such as anchors and boundary assertions.

The Java regular expression engine allows many predefined ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required