REGEX look arounds

Let’s have a look into the following examples first:

Example Type Description
data(?=data) Look ahead positive finds the 1st data (data which has data after it)
data(?!data) Look ahead negative finds the 2nd data (data which does not have data after it)
(?<=big)data Look behind positive finds the 1st bar (data which has big before it)
(?<!big)data Look behind negative finds the 2nd bar (data which does not have big before it)

Collectively, lookbehinds and lookaheads are known as lookarounds. The examples above give us a very basic syntax, but further down the track we encourage you to read the dedicated regex reference materials.

Get hands-on with 1200+ tech skills courses.