About the Regex Tester
The Regex Tester runs entirely in your browser — your code and data never leave your machine. Paste, click, copy the result.
Regular expressions are the shortest programming language with the steepest learning curve. This tester runs your pattern against the sample text live, lists every match with its capture groups, and lets you preview a replacement — all without leaving the page.
How to use this tool
- Enter the pattern (backslashes must be doubled in some inputs — the field shows standard regex).
- Set the flags:
gglobal (all matches),icase-insensitive,mmultiline,sdot-matches-newline. - Paste your test string and press Test.
- Optionally enter a replacement (use
$1,$2for capture groups) to preview the result.
Cheat sheet
| Pattern | Matches |
|---|---|
\d / \D | Digit / non-digit |
\w / \W | Word character / non-word |
^ / $ | Start / end of line |
[abc]+ | One or more of a, b or c |
(…) | Capture group → $1 |
a|b | Either a or b |
\b | Word boundary |
.*? | Lazy match (as little as possible) |
Practical examples
- Email (basic):
[\w.+-]+@[\w-]+\.[\w.]+ - US phone:
\(\d{3}\)\s?\d{3}-\d{4} - Extract numbers:
-?\d+(\.\d+)? - Slugify: pattern
[^a-z0-9]+, replace-
Who is this tool for?
Developers validating input patterns, content editors cleaning text data, and anyone who has forgotten why \d needs a double backslash.
Developer tip
Test against strings that should NOT match too — a pattern that matches everything is worse than no pattern. Start with small patterns and add complexity gradually.
Frequently asked questions
(a+)+ can hang the browser on long inputs. This page will recover, but avoid nested quantifiers in production code.