Skip to content
ToolZone

Regex Tester

Write a regular expression and test it live against sample text, with matches highlighted instantly so you can debug and refine your pattern.

Runs in your browser. Nothing you enter or upload leaves your device.

//g
Common patterns
2 matches
Matches highlighted
Contact ana@example.com or bob.smith+tools@mail.co.uk. Visit https://example.com/docs on 2026-11-15 from 192.168.1.20.
#IndexMatch
18ana@example.com
227bob.smith+tools@mail.co.uk

Uses your browser's JavaScript regex engine. Stops counting at 1000 matches.

Keyboard shortcuts

Run the main action
⌘ / Ctrl + Enter
Copy the result
⌘ / Ctrl + Shift + Enter
Download the result
⌘ / Ctrl + S
Paste a file or image into file tools
⌘ / Ctrl + V
Search all tools
⌘ / Ctrl + K
Show these shortcuts
?

You can also drop files anywhere on the page.

About the Regex Tester

Regular expressions are powerful but easy to get subtly wrong. This regex tester runs your pattern with JavaScript's built-in RegExp engine against sample text and highlights every match, so you can see exactly what a pattern catches before you put it in code.

How it works

The tool builds a RegExp object from your pattern and flags. With the g (global) flag, it calls exec repeatedly to collect every match and its position; if a match is empty, it advances one character so the loop always finishes. Without g, only the first match is found.

Each match is then wrapped in a highlight inside a copy of your test text, while the text between matches is shown unchanged. If the RegExp constructor throws an error, that message is displayed instead of a match count.

How to use

  1. 1

    Type your pattern between the slashes, or pick one from Common patterns.

  2. 2

    Click the flag buttons to turn g, i, m, s, u or y on and off.

  3. 3

    Paste or type sample text in the Test string box.

  4. 4

    Check the highlighted matches and the table of each match with its position and capture groups, or switch to Replace to try a replacement.

Worked examples

Find all numbers

Pulling numbers out of a sentence.

Input
Pattern = \d+, Flags = g, Text = Order 66 shipped on 2026-11-14
Result
4 matches found: 66, 2026, 11, 14

Case-insensitive search

Finding every form of a word.

Input
Pattern = cat, Flags = gi, Text = Cat catalog CAT
Result
3 matches found

Without the global flag

Only the first capitalized word.

Input
Pattern = [A-Z]\w+, Flags = (empty), Text = Hello World
Result
1 match found: Hello
Limitations
Only the JavaScript regex flavor is supported. Very slow patterns (catastrophic backtracking) can freeze the page, since the engine can't be stopped mid-match. Counting stops at 1,000 matches and the table lists the first 200.
Assumptions
Patterns are written in JavaScript RegExp syntax. Your browser supports the flags you enter.
Privacy
Patterns and test text are processed in your browser and are not sent or stored.

Frequently asked questions

Does this support different regex flavors?+

No. It uses JavaScript's RegExp engine, so features specific to PCRE, Python or Java, such as possessive quantifiers, may not work or may behave differently.

How do I test regex flags like case insensitivity?+

Click the flag buttons under the pattern. For example, turn on g and i to find all matches and ignore case.

Why does my pattern only match once?+

Without the g flag, JavaScript stops at the first match. Turn on the g flag to find every match.

Do I need to type the slashes?+

No. The slashes are shown for you; type only the pattern itself.

What does 'Invalid regular expression' mean?+

The pattern has a syntax error, such as an unclosed bracket or a quantifier with nothing before it. The message from the engine usually names the problem.

Related tools