Regex Tester
Test regular expressions live: enter the pattern and flags, see the highlighted matches in the text and the list of captured groups.
Text with matches highlighted
Captured groups
| Match | Group | Value |
|---|
Test regular expressions live: enter the pattern and flags, see the highlighted matches in the text and the list of captured groups.
| Match | Group | Value |
|---|
A regular expression (regex) is a pattern that describes a set of
strings. It's used to search, validate and
extract text: finding every email in a document, validating a
phone number format, replacing parts of a string, and much more. This tool uses
JavaScript's own regex engine (the same one used by String.prototype.match), so
results reflect your browser's behavior.
^ and $ match the start/end
of each line, not just the whole text.. also match line breaks.
Parentheses in a regex create capture groups: besides matching, they
store the matched part for you to reuse. For example,
(\d{4})-(\d{2}) captures the year and month separately. Named groups
((?<year>\d{4})) get a name instead of a number. This tool lists
each group captured per match.
The tool shows a readable error message (the same one from the JavaScript engine) and doesn't crash — the highlighting simply isn't applied until you fix the pattern.
a* with the g flag freeze the page?
Patterns that can match an empty string (zero-width) could cause an infinite loop.
The tool manually advances the position after each empty match, exactly as
recommended when iterating RegExp.exec.
Yes. The test text is never inserted as HTML. Each snippet (matched or not) is added
to the result as a text node or inside a <mark> via
textContent, which eliminates the risk of XSS.