Developer

Regex Tester

Test regular expressions against sample text with live matches.

All tools

Pattern

Matches (2)

toolbox
tools

Frequently asked questions

What does the global flag actually do in JavaScript regex?
The g flag makes the regex match every occurrence instead of stopping at the first, and it makes RegExp objects stateful through the lastIndex property. Methods like matchAll and replaceAll require it.
How do I match across multiple lines?
Use the m flag to make ^ and $ anchor to line starts and ends, and use the s flag to let the dot match newline characters. Combine them when you need both behaviors.
What's the difference between greedy and lazy quantifiers?
Greedy quantifiers like .* match as much text as possible and then backtrack, while lazy quantifiers like .*? match as little as possible and expand only when forced. Lazy matching is what you usually want between two delimiters.