Regex Tester

Test regular expressions with match highlighting and replace.

Processed locally — files never leave your device

Tested locally with your browser's regex engine. Nothing is uploaded. Updates live as you type.

Works offline once loaded Uploaded: 0 bytes

Paste a regular expression and some test text into this free tester and it highlights every match, lists the capture groups and positions, and can even run a find-and-replace. Everything runs in your browser with the JavaScript regex engine — the same engine your code will use — so your patterns and text never leave your device.

Regex is hard to reason about in your head — a pattern that looks right can match the wrong text, or nothing at all. Seeing the matches highlighted is the fastest way to know what a pattern really does. When a pattern confuses you, the Regex Explainer translates it into plain English, and the Regex Validator checks it for syntax errors.

How to use

  1. Type your regular expression and pick its flags.
  2. Paste the test text into the box.
  3. Read the highlighted matches and the match list with groups and positions.
  4. Try a replacement to preview find-and-replace before you use it in code.

Why use Toolsvine

Most regex testers send your pattern and text to a server. This one runs them locally with your browser's own regex engine — the same engine your JavaScript will use — so private data stays on your machine. It is free, needs no account and works offline once the page has loaded.

What does the regex tester do?

The tester compiles your pattern with your browser's JavaScript regex engine and runs it against the text you paste. Every match is highlighted in the preview, and each match is listed with its start and end position and its capture groups — the parts of the pattern in parentheses.

If the pattern cannot compile, you get the exact error instead of a blank result.

Captures are the point of most patterns, so the list shows them explicitly: group 1 is the first set of parentheses, group 2 the second, and so on, with named groups listed under their names. A pattern that matches but captures nothing still lists the match itself, so you can see whether the result is what your code will receive.

How do the flags change the result?

Flags change what the engine does with the pattern. The g flag finds every match instead of stopping after the first; i makes the match case-insensitive; m lets ^ and $ match at line starts and ends; and s lets a dot match newline characters as well.

FlagEffect
gFind every match, not just the first
iCase-insensitive — a matches A
m^ and $ match at line starts and ends
s. matches newlines too

Without the g flag the tester shows only the first match, which is the most common surprise for beginners: the pattern is fine, but the tester stopped after one match. Turn g on whenever you want to see everything a pattern catches.

What does a worked example look like?

The sample is an email pattern, \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b, run with the g flag against the sentence "Contact Alex Rivera at [email protected] or Jordan Lee at [email protected] for details." It finds two matches: [email protected] at positions 23–39 and [email protected] at positions 57–75.

Email regex finding two matches alex at example dot com and jordan at example dot com
Both addresses match; the replacement hides them without touching the rest of the text.

Type [email hidden] in the replacement box and the preview becomes "Contact Alex Rivera at [email hidden] or Jordan Lee at [email hidden] for details." — the rest of the sentence untouched, the two addresses replaced. That preview is exactly what your code will produce, which is why testing the replacement here is safer than discovering a mistake in production data.

How do capture groups and replacement work?

Parentheses create groups: (\d+)-(\d+) on 2026-11 captures 2026 as group 1 and 11 as group 2. Named groups, written (?<year>\d+), capture under a name instead of a number, and (?:…) makes a group you do not want to capture.

In the replacement box, $1 inserts the first capture group, $& inserts the whole match, and $$ inserts a literal dollar sign. So replacing with $1 on a date pattern keeps only the year, and the copy button copies the replaced text for pasting into your editor.

Frequently asked questions

Does this tester upload my pattern or text?

No. Everything runs locally in your browser with the built-in regex engine. Nothing leaves your device, and the tool works offline once the page has loaded. That matters when the test text is a customer record or a log line you would rather not send to a server — here it is never sent anywhere at all.

Why does my pattern only match once?

The g flag is off. Without it, the engine stops after the first match, so a pattern that should catch ten emails shows one. Check the g box — or add g to the flags — to see every match. The flag box accepts the letters d, g, i, m, s, u and y, and anything else produces a plain error instead of a silent wrong answer.

What do the numbers next to a match mean?

They are the start and end positions of the match in the text, counting from 0. Group numbers are the capture groups in order: group 1 is the first set of parentheses, group 2 the second, and so on. Named groups are listed under their names instead of numbers, and a group that did not participate in a match is marked as no match.

How does the replacement work?

Type a replacement string — $1 inserts the first capture group, $& inserts the whole match, $$ inserts a literal dollar sign. The preview shows the replaced text before you copy it, so you can see the effect on real data before committing to it. The copy button copies the replaced text, not the pattern, for pasting into your editor.

My pattern works here but not in my code. Why?

Two usual causes: the flags differ — make sure g, i and m match what your code uses — or the text differs, for example line endings (\r\n on Windows) or a different case. Copy the exact test text from your real input rather than retyping it, and check whether your code passes the pattern as a string, which needs doubled backslashes.

Can I test a regex from another language?

Mostly. JavaScript regex shares the core syntax with Python, PHP and most other languages, but some features differ — for example, Python's named-group spelling and its lookbehind support. A pattern valid elsewhere may fail here, and a pattern valid here may behave differently elsewhere, so always re-test in the target language before shipping.