Regex Lookaround

Lookahead and lookbehind assertions

Lookahead

(?=abc) # positive lookahead (followed by abc)
(?!abc) # negative lookahead (not followed by abc)

Lookbehind

(?<=abc) # positive lookbehind (preceded by abc)
(? # negative lookbehind (not preceded by abc)

Examples

\d+(?=px) # matches number followed by px
\$(?=\d+) # matches $ before digits
(?<=\$)\d+ # matches digits after $
\b\w+(?!ing\b) # words not ending with ing