Regex Tester

Popular

Live match highlighting & groups

//g

Hover a flag to see what it does.

3 matches· 0.14 ms

Highlighted matches

/ 3
The quick brown fox jumps over the lazy dog. The dog was not amused.

Matches 3

Match 1index 49quick
Match 2index 1015brown
Match 3index 2025jumps

Explanation

AI explanations coming soon
\bWord boundary
\wAny word character (a–z, A–Z, 0–9, _)
{5}Repeat exactly 5 times
\bWord boundary

Regex cheat sheet

Character classes

.
Any character except newline
\d
Any digit (0–9)
\D
Any non-digit
\w
Word character (a–z, A–Z, 0–9, _)
\W
Any non-word character
\s
Any whitespace
\S
Any non-whitespace
[abc]
Any one of a, b, or c
[^abc]
Anything except a, b, or c
[a-z]
Any character in the range

Anchors & boundaries

^
Start of string (or line with m)
$
End of string (or line with m)
\b
Word boundary
\B
Not a word boundary

Quantifiers

*
Zero or more
+
One or more
?
Zero or one (optional)
{n}
Exactly n times
{n,}
n or more times
{n,m}
Between n and m times
*?
Lazy — as few as possible

Groups & alternation

(…)
Capturing group
(?:…)
Non-capturing group
(?<name>…)
Named capturing group
\1
Backreference to group 1
|
Alternation — match either side

Lookaround

(?=…)
Lookahead — followed by
(?!…)
Negative lookahead
(?<=…)
Lookbehind — preceded by
(?<!…)
Negative lookbehind

Escapes

\.
A literal dot
\n
Newline
\t
Tab
\uFFFF
Unicode code point

Examples

Match every 5-letter word

Input
/\b\w{5}\b/g  ·  "The quick brown fox jumps"
Output
quick, brown, jumps

Capture a date with named groups

Input
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/  ·  "2026-07-14"
Output
year: 2026 · month: 07 · day: 14

What is Regex Tester?

Regex Tester is a fast, browser-based tool for writing, testing and debugging regular expressions. You type a pattern, paste some sample text, and every match is highlighted instantly — along with the capture groups each match produced.

Regular expressions are compact patterns for describing text: a phone number, an email address, a date, a log line, or anything with a repeating structure. They are powerful but easy to get subtly wrong, and a single misplaced quantifier can silently match too much or nothing at all. A tester lets you see exactly what your pattern does against real input before you paste it into your code.

This tool uses the same regular-expression engine your JavaScript runs on, so what you see here is what you get in the browser, in Node.js, and in most front-end code. It runs entirely on your machine — your patterns and test text never leave the page.

Why use an online regex tester?

Editing a regex directly in your code is a slow feedback loop: change the pattern, re-run the program, read the output, repeat. A dedicated tester collapses that loop to milliseconds. You see matches highlight as you type, so you can build a pattern incrementally and catch mistakes the moment they happen.

The live view also makes the invisible visible. It is hard to tell from a raw pattern whether .* is being greedy, whether your character class includes the hyphen you meant, or whether the g flag is actually finding every match. Highlighting answers those questions at a glance.

Because everything runs locally in your browser, there is nothing to install and nothing to upload. That matters when your test text is a real log file, a database dump, or anything you would rather not paste into a remote server. Private data stays on your machine.

How to test a regex step by step

Start with the smallest pattern that could work and grow it. Enter your expression in the pattern field — no surrounding slashes needed — then paste representative sample text below it.

As you type, matches light up in the text. Watch the results panel: it shows each full match plus every capture group, numbered $1, $2, and so on, with named groups labelled by name. If a group shows undefined, that part of the pattern did not participate in the match.

Toggle flags to change behaviour: g finds all matches instead of just the first, i ignores case, and m makes ^ and $ match at line breaks. When the highlighting matches your intent across every sample line, copy the pattern into your code with confidence.

Common use cases

Regular expressions show up everywhere text needs structure:

  • Validation — check that an email, phone number, postal code or username has the right shape before you accept it.
  • Extraction — pull dates, IDs, prices or URLs out of unstructured text and logs.
  • Search and replace — find every occurrence of a pattern and rewrite it, often paired with capture groups in the replacement.
  • Parsing logs — split a log line into timestamp, level and message using named groups.
  • Cleaning data — strip out unwanted characters, collapse whitespace, or normalise formatting.

Once your pattern is solid here, take it to a bulk Find & Replace to apply it across a whole document, or start from a description with the Regex Generator if you are not sure where to begin.

Tips & best practices

Anchor when you mean the whole string. Wrap validation patterns in ^ and $ so ^\d{5}$ matches exactly five digits — without anchors, a longer string with five digits inside it also passes.

Prefer specific classes over . A dot matches almost anything. If you want digits, write \d; if you want word characters, write \w. Narrow patterns are faster and less surprising.

Watch greedy quantifiers. .* grabs as much as it can and backtracks. Use the lazy form .*? or a negated class like [^"]* when you want to stop at the next delimiter.

Escape special characters. Dots, parentheses, plus signs and brackets have meaning in regex. To match a literal . write \..

Test the edge cases. Empty strings, extra whitespace, unicode characters and multi-line input all break naive patterns. Paste a few awkward samples and confirm the highlighting still holds.

Frequently asked questions

Is my test data uploaded anywhere?

No. Regex Tester runs entirely in your browser. Your pattern and test text never leave your machine, so it is safe to paste logs, dumps or other private data.

Which regex flavor does this use?

It uses the JavaScript (ECMAScript) regular-expression engine — the same one that runs in browsers and Node.js. Patterns that work here work in your JavaScript and TypeScript code.

Do I need to add the slashes around my pattern?

No. Enter just the pattern itself, for example \d{3}-\d{4}, and choose flags separately with the toggles. The tool assembles the full expression for you.

Why isn't my regex matching more than once?

You probably need the global flag. Without `g`, the engine stops at the first match. Turn on `g` to highlight every occurrence in the text.

How do I see capture groups?

Every match in the results panel lists its numbered groups ($1, $2, …) and any named groups you defined with (?<name>...). A group showing undefined did not take part in that match.

Can I test multiline text?

Yes. Paste multi-line input directly. Add the `m` flag so that `^` and `$` match at the start and end of each line rather than the whole string, and the `s` flag if you want `.` to match newlines too.

What if I don't know how to write the pattern?

Describe what you want to match with the AI Regex Generator, then bring the result here to test and refine it against real samples with live highlighting.

Related guides

Related tools