Regex Tester
Test JavaScript regular expressions directly in your browser. Enter a pattern, choose flags, and see matching results instantly.
About this tool
Test a JavaScript regular expression against sample text. Every match is listed with its index and capture groups, and the matched substrings are highlighted. All matching runs in the page.
How to use the Regex Tester
- Enter the pattern, without the surrounding slashes.
- Tick the flags you need.
- Paste the text to test against.
- Inspect the match list and the highlight.
JavaScript regex flags
- g — find all matches instead of stopping at the first.
- i — ignore letter case.
- m — make
^and$match at line breaks. - s — let
.match newline characters. -
u — Unicode mode: match by code point, allow
\p{…}property escapes, and make invalid escapes an error.
The sticky (y) and indices (d) flags are not
exposed. Sticky changes how the matcher advances between calls, and indices
only add offsets the list already shows.
Examples
Pattern: \b\d+\b (no flags)
Text: Order 123 contains 4 items.
Matches: 123, 4
Pattern: \p{Letter}+ (u)
Text: héllo 世界 123
Matches: héllo, 世界
Without the u flag the second pattern finds nothing: \p is not a
property escape there, so it is read as a literal p.
Limits
-
JavaScript syntax only. PCRE, Python, RE2 and Java differ: delimiters,
(?P<name>…)named groups and PCRE verbs are not accepted here. -
There is no timeout. A pattern with nested quantifiers, such as
(a+)+$against a long run ofa, can block the page while it backtracks. There is no cancel button; close the tab. - Zero-length matches are counted but not highlighted, because there is no range to mark.
- Lookbehind and named groups work where the browser supports them; the tester reports a syntax error when it does not.
Frequently Asked Questions
What regex syntax does this tool use?
JavaScript RegExp, as implemented by your browser — the same
engine as String.prototype.match and
RegExp.prototype.exec.
Why is my regex invalid?
Unbalanced groups or brackets, invalid escapes and bad quantifiers all
throw. With u enabled, escapes that are tolerated without it
become errors.
What does the g flag change?
Without it the tester reports only the first match. With it, the
matcher continues from lastIndex until it runs out of text.
Is my text uploaded?
No. The pattern and the text are matched in the page.