Test JavaScript regular expressions against your text with live highlighting, capture groups, and a replace preview. Each pattern is explained token by token, and the tool generates ready-to-run JavaScript. Matching runs in a background worker, so a runaway pattern stops instead of freezing the page.
Type a pattern in Regular expression, or pick one from Common patterns. Pasting /pattern/flags fills in the flags too.
Toggle the flags you need, such as g, i, m, or s.
Paste your text into Test string. Matches are highlighted; hover one to see its groups.
Use the Matches, Explanation, and Code tabs, or turn on Replace to preview the result of string.replace().
JavaScript, the engine built into your browser. Flags g, i, m, s, u, y, d, and v are supported. Syntax specific to PCRE, Python, or Java may behave differently.
Without the g flag, JavaScript stops at the first match. Turn on g (global) to find them all.
The pattern took too long on this text, usually from catastrophic backtracking with nested quantifiers like (a+)+. Make the inner parts more specific or anchor the pattern.
Write $<name> for a named group, $1 for a numbered one, and $& for the whole match. The buttons under Replace with insert these tokens.
Your text is never uploaded. The pattern, flags, and replacement are remembered in this browser; the test string is not.