Regex Tester - Test & Debug Regular Expressions Online (Free)

Test and debug any regular expression in real time. Matches highlight instantly, data stays in your browser. Free regex tester — no sign-up needed.

Tool options

Flags

Replace

Presets

//g3 matches
Test text
Matches (3)

Matches (first 3)

Regex cheat sheet
\d \w \sdigit · word char · whitespace
\D \W \Snegations of the above
.any char (newlines too with the s flag)
^ $start / end (per line with m)
[abc] [^abc]character set / negated set
a* a+ a?0 or more · 1 or more · optional
a{2,5}between 2 and 5 repetitions
a+?lazy - match as little as possible
(x) (?:x)capture group / non-capturing group
(?<name>x)named capture group
x|yalternation - x or y
\bword boundary
(?=x) (?!x)lookahead / negative lookahead
(?<=x) (?<!x)lookbehind / negative lookbehind
$1 $<name> $&replacement: group · named group · whole match

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

  1. Type or paste your regex into the pattern field (no surrounding slashes needed).
  2. Set your flags — tick g for global (find all matches), i to ignore case, or others as needed.
  3. Paste your test string into the text area below.
  4. 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
\dAny digit (0–9)\d{4} matches 2024
\wAny word character (letter, digit, or underscore)\w+ matches hello_2
\sAny 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 lazycolou?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 sidecat|dog matches cat or dog
\bWord boundary — the edge between a word character and a non-word character\bcat\b won't match inside concatenate

Flags

  • gGlobal: find all matches, not just the first.
  • iIgnore case: Cat, CAT, and cat all match.
  • mMultiline: ^ and $ match the start/end of each line, not just the whole string.
  • sDotall: 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 DOMParser in JS or BeautifulSoup in 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.

Frequently asked questions

Is my text uploaded to a server when I use this regex tester?+
No. Everything runs inside your browser using JavaScript's built-in RegExp engine. Your pattern and test text never leave your device, so it's safe to use with private data, credentials, or internal logs.
Do I need to add slashes around my regex pattern?+
No — just type the pattern itself (e.g. \d{4}-\d{2}-\d{2}). The tool handles the delimiters. Slashes are a code-syntax convention, not part of the pattern.
Why does my regex work here but not in Python?+
This tester uses the JavaScript regex engine, which differs from Python's re module in a few ways. The biggest ones: Python uses (?P<name>...) for named groups (JavaScript uses (?<name>...)), and Python doesn't support the s (dotall) flag using the same letter — use re.DOTALL instead. Always test the final pattern in your actual language.
How do I use this pattern in VS Code?+
Open the Find bar (Ctrl+F / Cmd+F), click the .* icon to enable regex mode, then paste your pattern. VS Code uses the same JavaScript/PCRE-flavoured engine, so patterns from this tester work directly.
What does 'g flag' mean and do I always need it?+
The g (global) flag tells the engine to find all matches in the text rather than stopping after the first one. Without it, only the first match is returned. Turn it on whenever you expect multiple results.
What's the difference between a regex tester and a regex debugger?+
They're often the same thing. A regex tester (or regex checker / pattern tester) shows you which parts of your text match. A regex debugger shows you step-by-step how the engine works through the pattern. This tool focuses on real-time match highlighting — the most common need.
Is this tool free? Do I need to sign up?+
Completely free, and no account needed. Open the page and start testing immediately.
Can I test very long strings or large log files?+
Yes, up to a point. Because matching happens in your browser, very large inputs (several megabytes) may slow down your tab. For giant log files, copy a representative sample instead of pasting the whole file.