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

Negative lookbehind

A negative lookbehind assertion asserts true if the pattern inside the lookbehind is not matched.

Here is its syntax:

(?<!...) 

For example, (?<!xyz)abc asserts that there cannot be the string, xyz, just before matching the string, abc.

Here are a few important points about lookaround regex patterns:

  • Lookaround patterns are atomic. Like atomic groups, once a lookaround pattern is matched, the regex engine exits immediately from that lookaround, returning just a true or false assertion.
  • Lookaround patterns don't move from the current position. All patterns are evaluated from the current position. The position remains the same after the lookaround assertions are completed.
  • If a regular expression uses multiple lookaround ...

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