Test any regular expression against real text, right here
Paste your pattern and your text into the tool above, and it highlights every match in real time. No sign-up, no waiting, no guessing whether your regex actually works.
How to use the regex tester
- Type or paste your regex into the pattern field (no surrounding slashes needed).
- Set your flags — tick
gfor global (find all matches),ito ignore case, or others as needed. - Paste your test string into the text area below.
- Matches highlight instantly. Hover a match to see which capture group it came from.
Worked example: validating a date string
Say you want to find dates in the format YYYY-MM-DD inside a block of text.
Pattern: \b\d{4}-\d{2}-\d{2}\b
Flags: g
Test string:
Order placed on 2024-03-15. Delivery expected 2024-03-22. Invoice date: not confirmed.
Result: Two matches — 2024-03-15 and 2024-03-22 — highlighted. The phrase "not confirmed" is correctly skipped.
How to use the same pattern in code
Once your pattern works here, drop it straight into your project.
JavaScript
const pattern = /\b\d{4}-\d{2}-\d{2}\b/g;
const text = 'Order placed on 2024-03-15. Delivery expected 2024-03-22.';
const matches = text.match(pattern);
console.log(matches); // ['2024-03-15', '2024-03-22']
Python
import re
pattern = r'\b\d{4}-\d{2}-\d{2}\b'
text = 'Order placed on 2024-03-15. Delivery expected 2024-03-22.'
matches = re.findall(pattern, text)
print(matches) # ['2024-03-15', '2024-03-22']
Python's re module and JavaScript's built-in RegExp share most syntax, so patterns from this tester usually transfer with minimal changes. The main exception: Python uses (?P<name>...) for named groups; JavaScript uses (?<name>...).
How the regex tester works under the hood
The tester runs on the JavaScript RegExp engine built into your browser — the same engine Node.js and every modern browser use to execute String.prototype.matchAll() and friends. Your pattern is compiled client-side, and matches are computed locally with each keystroke.
Your text never leaves your device. Nothing is uploaded to any server, so it's safe to paste API keys, log files, or private data while debugging.
The authoritative reference for the JavaScript regex spec is MDN: Regular Expressions.
Regex cheat sheet – the most-used tokens at a glance
Bookmark this table. It covers the building blocks you'll reach for in almost every pattern.
| Token | Meaning | Quick example |
|---|---|---|
\d | Any digit (0–9) | \d{4} matches 2024 |
\w | Any word character (letter, digit, or underscore) | \w+ matches hello_2 |
\s | Any whitespace (space, tab, newline) | \s+ matches one or more spaces |
. | Any single character except newline (unless s flag is set) | c.t matches cat, cut |
^ | Start of string (or start of line with m flag) | ^Hello matches only at the very beginning |
$ | End of string (or end of line with m flag) | end$ matches only at the very end |
* | Zero or more of the preceding item (greedy) | \d* matches or 123 |
+ | One or more of the preceding item (greedy) | \d+ matches 1 or 4567 |
? | Zero or one of the preceding item; also makes a quantifier lazy | colou?r matches color and colour |
{n,m} | Between n and m repetitions | \d{2,4} matches 12 to 1234 |
[...] | Character set — any one character inside the brackets | [aeiou] matches any vowel |
(...) | Capture group — saves the matched text for later use | (\d{4}) captures a 4-digit year |
| | Alternation — matches either the left or right side | cat|dog matches cat or dog |
\b | Word boundary — the edge between a word character and a non-word character | \bcat\b won't match inside concatenate |
Flags
g— Global: find all matches, not just the first.i— Ignore case:Cat,CAT, andcatall match.m— Multiline:^and$match the start/end of each line, not just the whole string.s— Dotall: makes.match newline characters too.
Greedy vs. lazy quantifiers
By default, *, +, and {n,m} are greedy — they grab as many characters as possible. Add a ? after them to make them lazy (take as few as possible).
Example: Against the string <b>bold</b>, the pattern <.+> greedily matches the whole thing. The pattern <.+?> lazily matches just <b>.
When to use a regex tester — and when not to
Great use cases
- Validating formats: email addresses, phone numbers, postal codes, dates.
- Scraping or extracting specific values from logs, CSVs, or raw text.
- Find-and-replace across a codebase (VS Code and most editors accept regex in their search bar).
- Quickly checking whether an existing pattern from Stack Overflow actually matches your data before you ship it.
When regex isn't the right tool
- Parsing HTML or XML: use a proper parser (like
DOMParserin JS orBeautifulSoupin Python). Regex breaks on nested or malformed markup. - Parsing JSON: use
JSON.parse()— regex can't reliably handle nested structures. - Full email validation in production: the RFC 5321 spec for valid email addresses is far too complex for a regex. A regex can catch obvious typos; for anything critical, use a library or a verification API.
Ready to test your pattern? Paste it into the tool above and see your matches highlighted in real time.