Skip to content
Regex

Lookaround

Zero-width assertions around a position.

#lookahead#lookbehind#assertion

Code

regex
(?=abc)     positive lookahead
(?!abc)     negative lookahead
(?<=abc)    positive lookbehind
(?<!abc)    negative lookbehind
a(?=b)      a followed by b
a(?!b)      a not followed by b
(?<=a)b     b preceded by a
(?<!a)b     b not preceded by a