Regex Tester
Build, test and debug JavaScript regular expressions with live highlighting, replace mode and ready-to-use presets.
What is a regular expression?
A regular expression (regex) is a tiny pattern language for searching and transforming text. It powers find-in-files, log analysis, validation rules, lexers, and most search-and-replace features in editors. This tool builds a live RegExp in your browser, runs it against the test string, and shows every match plus an inline highlight. It uses the standard JavaScript engine, so what works here works the same in Node.js and every modern browser.
How to use the tester
Type your pattern (without the wrapping /.../) into the pattern field, pick the flags you need, and paste your test text below. Matches are highlighted in the preview pane and listed individually with their character positions. Toggle Replace mode to see the result of String.prototype.replace() with your replacement string — use $& for the whole match and $1, $2 for capture groups. The preset chips load common patterns into the field so you can tweak instead of starting from scratch.
Regex cheat sheet
The most useful tokens, in one place. JavaScript regex follows the ECMAScript syntax — close to PCRE but with a few omissions (no possessive quantifiers, no recursive patterns).
| Token | Meaning |
|---|---|
. | Any character (except newline, unless the s flag is set) |
\d \w \s | Digit, word character (letters/digits/_), whitespace |
^ $ | Start of string, end of string (per line with the m flag) |
* + ? | Zero or more, one or more, zero or one (greedy by default) |
{n,m} | Between n and m repetitions |
[abc] | Any character in the set; use [^abc] to negate |
(...) | Capture group; use (?:...) for a non-capturing group |
| | Alternation — match either side |
Frequently asked questions
Which regex engine does this use?
What do the flags mean?
g finds all matches (not just the first). i ignores case. m makes ^ and $ match line starts/ends. s lets . match newlines. u enables full Unicode mode (required for properties like \p{Letter}). y is sticky — matches must start exactly at lastIndex.Is anything sent to a server?
new RegExp() and String.prototype.replace(). Open DevTools > Network and confirm: no requests are made when you type. Safe for log snippets, internal data, or anything you wouldn't paste into a hosted regex sandbox.Why is my regex slow or freezing the page?
(a+)+ or (.*)* can run for billions of steps on inputs that almost match. Avoid nesting +/*; prefer atomic-style alternatives like [^x]+ or anchor your pattern. The tester guards against runaway matches with a 50,000-iteration cap so the page doesn't lock up.How do I use capture groups in Replace mode?
$1, $2, etc. Example: pattern (\w+)@(\w+) with replacement $2 / $1 swaps the user and domain in an email. $& means the whole match, $$ outputs a literal $. Named groups (?<name>...) can be used as $<name>.Why don't my ^ and $ match each line?
^ matches only the very start of the test string and $ only the very end — not each line. Add the m (multiline) flag and they'll match line breaks. If you also need . to match newline characters (for example when grabbing across lines), add the s (dotAll) flag.
EN
PT
ES