.*

Regex Tester

Test JavaScript regular expressions live — see matches highlighted as you type.

regex-tester
//
// test string

About Regex Tester

Regular expressions are one of the most powerful and most misunderstood tools in a developer's toolkit. This regex tester lets you write a pattern, set flags (global, case-insensitive, multiline, dotAll), and see every match highlighted in your test string in real time. The tool uses JavaScript's native RegExp engine, so results match exactly what you'd get in Node.js, browser JavaScript, or any JS runtime. No translation layer, no guessing — what you see here is what your code will see. As you type, the match count updates instantly and each match is highlighted with its capture groups listed below. This makes it easy to iterate on complex patterns — tweak a quantifier, add a lookahead, adjust a character class — and immediately see the effect. Useful for validating email addresses, phone numbers, URLs, and date formats; extracting data from log files; parsing structured text; writing search-and-replace patterns for editors; and understanding patterns in third-party code. The flags panel supports g (global), i (case-insensitive), m (multiline), and s (dotAll) — the same flags supported by JavaScript's RegExp.

How it works

Every time you edit the pattern or the flags, the tool compiles a fresh regular expression with new RegExp(pattern, flags). If the pattern is malformed — an unbalanced bracket, a dangling quantifier — the constructor throws, and that error is surfaced instead of a match list, so you get immediate feedback while typing. Once compiled, the expression is run against your test string to collect matches. With the global flag set, the tool iterates every match (the equivalent of String.matchAll) rather than stopping at the first, and for each result it reads the match's index and length to highlight the exact span in your text. Capture groups — both numbered and named (?<name>...) — come straight off the match array, which is why the group values shown below the highlights are precisely what your own code would receive from .exec() or .match(). Because it's the same V8/SpiderMonkey engine your runtime uses, there's no dialect translation: lookaheads, lookbehinds, and Unicode property escapes behave identically.

Frequently Asked Questions

What regex flavor does this tester use?
JavaScript (ECMAScript) regex via the built-in RegExp object. This matches behavior in Node.js, V8, SpiderMonkey, and all modern browsers. It supports standard features like lookaheads, lookbehinds, named capture groups, and Unicode property escapes (with the u flag).
What do the flags g, i, m, and s do?
g (global) finds all matches instead of stopping at the first. i (case-insensitive) treats A and a as the same. m (multiline) makes ^ and $ match the start/end of each line, not just the whole string. s (dotAll) makes the . character match newlines too.
How do I match a literal dot or parenthesis?
Escape them with a backslash: \. matches a literal dot, \( matches a literal opening parenthesis. In a regex pattern, unescaped . means "any character" and ( starts a capture group.
Why does my regex match too much or too little?
Quantifiers (*, +, ?) are greedy by default — they match as much as possible. Add ? after them to make them lazy: .*? matches the shortest possible string. Also check your anchors: ^ and $ only match line boundaries with the m flag, otherwise they match the whole string start/end.
Can I use named capture groups?
Yes. Use (?<name>...) syntax. Named groups make your pattern self-documenting and let you reference captures by name in replacement strings: str.replace(/(?<year>\d{4})/, "$<year>"). The tester shows named group values in the match details.