Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Basics

Look around basics

Lookarounds often cause confusion to new regex learners. There are four
lookarounds:

(?<= … ) and (?= … ),

(?<! … ) and (?! … )

Collectively, lookbehinds and lookaheads are known as lookarounds. Let’s see


the following table of examples:

Lookaround Name What it Does

Asserts that what


immediately follows
(?=learn) Lookahead
the current position in
the string is learn

Asserts that what


immediately precedes
(?<=learn) Lookbehind
the current position in
the string is learn

Asserts that what


immediately follows
(?!learn) Negative Lookahead
the current position in
the string is not learn

(?<!learn) Negative Lookbehind Asserts that what


immediately precedes
the current position in
the string is not learn

You might also like