Skip to content

Regex Tester

Write a JavaScript regular expression and see every match highlighted as you type, with capture groups, a replace preview and ready-made patterns. Runs in a sandboxed worker, so a runaway pattern can’t freeze the page.

RunsIn browser
Sign-upNone
UploadsZero
Presets


  
Matchesfirst 500 shown
#IndexMatchGroups
Cheat sheetclick to insert

How it works

Patterns use the JavaScript regex engine built into your browser — the same one Node.js, Deno and every browser use — so what matches here matches in your code. Most syntax is shared with PCRE, Python and Java, but a few features differ (JavaScript has no possessive quantifiers, atomic groups or inline (?i) modifiers).

Matching runs in a background Web Worker. If a pattern takes longer than 1.5 seconds — usually catastrophic backtracking from nested quantifiers like (a+)+$ — it is stopped and reported instead of freezing the tab. Nothing you type is sent anywhere; “Copy link” puts the pattern and test text in the URL fragment, which never reaches a server.

Questions

What do the regex flags g, i, m, s, u and y do?

g finds every match instead of the first. i ignores case. m makes ^ and $ match at each line. s lets . match newlines. u enables full Unicode, including \p{L} property escapes. y (sticky) only matches at the current position.

How do I use a capture group in the replacement?

Use $1, $2… for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign. Turn on Replace to preview the result live.

Why does my email regex not match every valid address?

The full email grammar (RFC 5322) is far too permissive for a practical regex. The preset catches the addresses people actually type; for real validation, send a confirmation email.

Why does my pattern match an empty string?

Quantifiers like * and ? can match zero characters, so a pattern such as \d* matches at every position. Empty matches are shown as a thin marker; use + instead of * if you need at least one character.

How do I escape a special character?

Put a backslash before it: \. matches a literal dot, \( a parenthesis, \\ a backslash. Inside a character class most characters are literal, so [.] also matches a dot.