Skip to content

Positive Lookaheads

Find expression xx where expression yy follows:-

Suppose you need to match all the first names ending with last name Picasso. You could write the following pattern to solve it.

([a-zA-Z ]+)(?=Picasso)

Regex Breakdown

Paloma Picasso // => true
Maya Picasso // => true
Steve Ross // => false

To experiment, navigate to the Regex101 sandbox I’ve created. This RegEx only works with Non-Deterministic Automata (NFA) regex engines.

Reading list

Thanks for reading.

Follow the RSS feed · Say hi on LinkedIn

Human Agent