How to use this regex tester
- Type your pattern in the top field, just the body, no surrounding slashes. For example,
\b\w+@\w+\.\w+\bto find simple email-like strings. - Pick your flags with the checkboxes:
gfinds every match (not just the first),iignores letter case,mmakes^and$match at every line, andslets.match newlines too. - Read the What this pattern does panel for a plain-English, token-by-token breakdown of your pattern, anchors, character classes, quantifiers, groups and lookarounds are all called out as you type.
- Paste your test text into the box below. Matching runs instantly on every keystroke, no button to press.
- In Match mode, the Matches counter shows how many were found, and each match is listed with its position and any capture groups.
- Switch to Replace mode to try a substitution: type a replacement using
$1,$2… for capture groups or$<name>for named groups, and the result preview updates live. - Copy the matches or the replaced result to your clipboard, or Clear to start fresh.
- Stuck on syntax? The regex quick reference below the tool is a static cheatsheet of anchors, character classes, quantifiers, groups and flags.
A quick refresher on regular expressions
A regular expression (regex) is a tiny pattern language for describing text. Plain characters match themselves, while special tokens describe shapes: \d is any digit, \w a word character, \s whitespace, and . any character. Quantifiers say how many, * (zero or more), + (one or more), ? (optional) and {2,4} (a range). Brackets like [a-z] define a character set, and parentheses (.) create a capture group so you can pull out just the part you care about.
This tool uses the JavaScript regex engine built into your browser, so what you see here is exactly what String.prototype.match and RegExp.prototype.exec will do in your own JavaScript or Node.js code, including how capture groups, named groups (?<year>\d{4}) and the global flag behave. That makes it a faithful scratchpad for front-end and back-end developers alike.
Capture groups and match positions
Every result shows the full match plus its index (the zero-based character position where it starts). If your pattern contains parentheses, each capture group is listed beneath the match in order, and named groups are shown by name. A group that did not participate in the match appears as undefined, useful for spotting optional branches that did or did not fire. With the g flag off, only the first match is returned, mirroring how a non-global exec behaves.
Plain-English explanation, replace mode and the cheatsheet
The What this pattern does panel walks your pattern token by token and explains each piece in plain English, anchors, character classes, quantifiers (including whether they are greedy or lazy), groups, alternation and lookaround are all called out as you type. It is a solid breakdown of common syntax, not a full regex parser, so anything it does not recognize is labelled honestly as an unrecognized token instead of guessed at.
Switch to Replace mode to preview a substitution. Type a replacement using $1, $2… to reference capture groups or $<name> for named groups, exactly like JavaScript's ownString.prototype.replace, because that is exactly what runs under the hood. The result preview updates live as you edit the pattern, flags, replacement or test text.
The regex quick reference underneath the tool is a static cheatsheet, always visible, covering the same anchors, character classes, quantifiers, groups and flags in one place. The illustrative email, URL and phone patterns in it are simplified examples, not production-ready validation regex.
Frequently asked questions
Do I include the slashes, like /abc/g?
No. Type only the pattern body (abc) in the pattern field and set the flags with the checkboxes. Adding literal slashes would make them part of the pattern.
My pattern matches forever or is slow, why?
Some patterns (often nested quantifiers like (a+)+) can cause catastrophic backtracking on certain inputs. Simplify the pattern or anchor it. Zero-width matches are handled safely here so the tool will not loop infinitely.
Does it support named capture groups and lookbehind?
Yes, it runs the modern browser regex engine, so named groups (?<name>…), lookahead and lookbehind all work in any up-to-date browser.
How does the plain-English explanation work?
A hand-written tokenizer walks your pattern and matches recognizable constructs (anchors, character classes, quantifiers, groups, common escapes, lookaround) to a description. It covers common, well-known syntax rather than every possible construct, unusual or obscure tokens are labelled as unrecognized instead of misdescribed.
Is the replace preview a real JavaScript replace?
Yes. It calls your test text's own .replace() with the RegExp built from your pattern and flags, and your replacement string, so $1, $2 and $<name> behave exactly as they would in your own code.
Are the cheatsheet's example patterns safe to use in production?
Treat them as illustrative only. Real email and URL validation is notoriously hard to get exactly right, these short examples will reject some valid input and accept some invalid input in edge cases. For anything that matters, use a dedicated validation library or a server-side check.