Negative lookahead

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

The following is its syntax:

(?!...) 

For example, abc(?!xyz) asserts that there cannot be a string, xyz, immediately after matching the string abc.

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.