Regex (?=...) — Positive Lookahead

(?=...) is a positive lookahead that matches a position where the pattern ... follows, without consuming those characters. Example: /foo(?=\d)/ matches "foo" only when a digit follows.

Open the interactive DevRef Hub tool →

Key facts

Token(?=...)
TypeZero-width lookahead
ConsumesNo characters
Example/foo(?=\d)/ on "foo123" → "foo"

Frequently asked questions

What is a positive lookahead?

An assertion that the following text matches, without consuming it.

Lookahead vs lookbehind?

Lookahead (?=...) checks ahead; lookbehind (?<=...) checks behind.

Related pages

Regex (?=...) — Positive Lookahead is part of DevRef Hub on GOAT Lab — a free reference you can use without signing up, and it works offline. Open the tool above for any custom value.

Advertise

Part of GOAT Lab — 26 free, browser-based science, engineering and developer tools. No sign-up.