Blog

Lookforward and Lookbehind When Using Regular Expressions

Regular expressions are powerful tools for string identification. They include special cases known as "lookahead" and "lookbehind," which are described below:

Lookahead The current position is followed by "test":

(?=test)

Lookbehind The current position is preceded by "test":

(?<=test)

Negative Lookahead The current position is not followed by "test":

(?!test)

Negative Lookbehind The current position is not preceded by "test":

(?<!test)