Regex Tester
Build and debug regular expressions interactively. Matches light up inside the test text as you type, capture groups break out into a table, and a replace mode lets you preview rewrites. Powered by your browser's native RegExp engine — your pattern never leaves the page.
Enter a pattern to see matches.
Pattern in, matches out
Every match returns its value, position, and any capture groups. Replace mode runs String.prototype.replace with your replacement string — $1, $2, $&, and named groups all work.
\b(\w+)oxes?\b
1. "boxing" at 49 · groups: ["b"] 2. "box" at 99 · groups: ["b"]
What you'll use this for
Regular expressions are the swiss-army knife for text: validation, parsing, extraction, search-and-replace. This tester gives you a tight feedback loop without a console.
Validate input
Sketch a pattern for an email, phone, slug, or postcode and see exactly which inputs slip through.
Extract data
Pull dates, IDs, or URLs out of logs and unstructured text — capture groups appear in a table.
Bulk rewrite
Flip replace mode on and preview a search-and-replace before pasting it into your editor.
Learn regex
Tweak flags one at a time and watch the match set shift. Faster than reading the spec.
How to test a regular expression
Drop in your text
Paste the sample you want to match against into the left editor. Multi-line is fine — flip the m flag if anchors need to act per line.
Write the pattern
Type the regex body into the Pattern field. Skip the surrounding slashes — flags are toggled separately as checkboxes below.
Read the matches
Each match shows up highlighted in the test text and listed with its index plus capture groups. Invalid regex turns the result panel red.
Try replace mode
Flip Replace mode on, write a replacement (using $1 for the first capture), and preview the rewritten string.
Frequently asked questions
As you edit your pattern, CodeMirror's markText API wraps every match range with a translucent blue background directly inside the test-text editor. The marks are cleared and rebuilt on every keystroke, so the highlights stay in sync with whatever you typed.
All JavaScript RegExp flags: g (global), i (case-insensitive), m (multiline — ^/$ match per line), s (dotall — . matches newlines), u (full Unicode), and y (sticky). Toggle each independently with the flag switches.
Yes. Modern Chromium, Firefox, and Safari all support (?<=…) and (?<!…) lookbehinds in JavaScript RegExp. The tester uses your browser's native engine, so anything the browser parses is supported — including named captures (?<name>…).
No. The pattern, test text, and replacement string are evaluated entirely in-browser by the native RegExp constructor. Nothing is sent to a server — close the tab and it's gone.
By default ^ and $ match the start and end of the entire string. To anchor to the start/end of each line, enable the m (multiline) flag. Likewise, . won't cross a newline unless you turn on the s (dotall) flag.
About JavaScript regular expressions
Regular expressions are mini-programs for matching patterns in strings. JavaScript's RegExp follows the ECMAScript spec, which today is a near-superset of Perl-compatible regex — with native named captures, lookbehinds, and Unicode property escapes.
Pattern building blocks
- Character classes —
\w,\d,\s, plus custom sets like[a-z]or negations[^A-Z]. - Quantifiers —
*,+,?,{2,5}, with lazy variants like+?. - Anchors & boundaries —
^,$,\bfor word boundaries. - Groups —
(…)for captures,(?:…)for non-capturing,(?<name>…)for named.
Tips that save hours
- Test against the worst input you can think of — empty strings, very long lines, lookalike Unicode.
- Prefer non-capturing groups when you don't need the value; they're cheaper and the table stays tidy.
- Anchor when you can. An unanchored
\d+on long input is dramatically slower than a bounded one.