14 chars · 1 line
8 chars · 1 line
14 chars · 1 line
8 chars · 1 line
Regex lookahead behavior
Positive lookahead (?=...) checks what comes next without consuming it. The preloaded pattern returns 42 because it is followed by USD, while the USD text itself is not part of the match. This tool is free to use. No account or payment is required.
Last updated
A successful lookahead can inspect characters after the current position, but those asserted characters are not consumed into the complete match. This is useful when context controls eligibility but should remain outside the extracted value.
Match a number only when USD follows.
\d+(?= USD) / g
42 USD, 19 EUR42Common questions
No. Positive lookahead checks the following context without consuming it into the complete match.
Yes. The assertion can contain regex syntax supported by JavaScript, subject to the usual performance and compatibility considerations.
Negative lookahead (?!...) succeeds when the specified following pattern does not match.
Debugging a specific Regex issue? Browse Regex troubleshooting.