Regex Tester
Test regular expressions in real time. See matches highlighted in your text, capture groups, and match positions. Common patterns library included.
Matches will appear here…
What the tester does
Your pattern is compiled with new RegExp() on every keystroke and run against the test string, so results track what you type. The pattern box shows the delimiters and active flags the way you would write the literal in code. Nothing is uploaded — it all runs in the page.
- Highlighted preview — your test string with every match marked in place, so you can see what got skipped.
- Match list — each hit with its character index and its numbered capture groups.
- Flag toggles —
g,i,m,s. - Live syntax errors — an unbalanced bracket reports the engine's own message instead of silently matching nothing.
- Patterns menu — eight common patterns, each loading its own recommended flags.
Common regex mistakes
- Missing the g flag — without it you get exactly one match. Most “my regex only finds the first one” reports are this.
- Unescaped dot —
example.comalso matchesexampleXcom. Writeexample\.com. - Greedy quantifiers —
<.*>swallows a whole line of HTML.<.*?>stops at the first>. - Anchors on multiline input —
^and$bind to the whole string until you addm. - Double escaping — in a literal it is
/\d+/, but through the constructor it isnew RegExp("\\d+"). Paste patterns into this page in literal form. - Reusing a /g regex — a global regex keeps
lastIndexbetween calls, so a second.test()on the same object can return false. Build a fresh one per use. - Nested quantifiers —
(a+)+$against a long non-matching string backtracks catastrophically. If the browser hangs on your pattern, that is why.
Essential regex patterns for developers
Copy any of these into the tester above to see it match against your input:
| Pattern | Matches | Flags |
|---|---|---|
| /^[\w.-]+@[\w.-]+\.\w{2,}$/ | Email address | i |
| /https?:\/\/[^\s]+/ | URL (http/https) | g |
| /^\+?[1-9]\d{6,14}$/ | International phone | — |
| /^#([a-f0-9]{6}|[a-f0-9]{3})$/ | Hex color | i |
| /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/ | ISO date (YYYY-MM-DD) | — |
| /\b(?:\d{1,3}\.){3}\d{1,3}\b/ | IPv4 address | g |
| /^[a-z][a-z0-9-]*$/ | Slug / URL-safe string | i |
| /^[a-zA-Z_$][\w$]*$/ | Valid JS identifier | — |
Regex flags explained
g(global) — find all matches, not just the first onei(case insensitive) — treat uppercase and lowercase as equalm(multiline) —^and$match the start/end of each line, not just the whole strings(dotall) —.matches newline characters too, useful for multi-line blocks
JavaScript also has u, v, y and d. They are not exposed as toggles here, so test those in your own runtime.
Using regex in JavaScript
const email = /^[\w.-]+@[\w.-]+\.\w{2,}$/i;
// Test if a string matches
email.test("user@example.com"); // true
// Extract all matches from a string
const text = "Contact alice@x.com or bob@y.org";
text.match(/[\w.-]+@[\w.-]+\.\w{2,}/g);
// → ["alice@x.com", "bob@y.org"]
// Replace matches
"Hello World".replace(/\b\w/g, c => c.toLowerCase());
// → "hello world"Related text tools
Frequently Asked Questions
Which regex engine does this use?
JavaScript's built-in RegExp, the same engine as Node.js and every browser. Patterns that work here work in your JS code. PCRE-only syntax such as lookbehind alternatives or recursion will not.
Why am I only seeing the first match?
The g flag is off. Without it, JavaScript stops at the first match by design. Toggle g and the full match list and highlighting appear.
What are capture groups, and are named groups supported?
Parenthesised parts of your pattern, listed per match so you can pull out pieces of a hit. Named groups match correctly but are listed by number here, not by name.
Does it include common patterns to start from?
Yes — a Patterns menu with eight ready-made ones: email, URL, IPv4, US phone, hex colour, ISO date, HTML tag, and digits only. Picking one fills in both the pattern and its flags.
How does this compare to regex101?
It covers live matching, highlighting, groups, indices, and flags with no ads and no signup. It does not have a substitution pane or a pattern-explanation panel, so reach for regex101 when you need those.