Regex Tester
Test and debug regular expressions in real time. Highlight matches, inspect capture groups, and toggle g/i/m/s/u flags — all in your browser.
Enter a pattern and test text above — matches highlight in real time.
Regex Tester — Test and Debug Regular Expressions Instantly
Regular expressions are one of the most powerful and misunderstood tools in a developer's arsenal. A single well-crafted pattern can replace dozens of lines of string-manipulation code, but a missing backslash or the wrong flag can make it silently match nothing — or worse, match the wrong thing entirely. This Regex Tester lets you iterate on a pattern and see every match highlighted in your test text in real time, so you can build confidence before committing the expression to your codebase.
How to Use the Tester
- Enter your pattern in the pattern field (without the surrounding slashes — those are shown for readability only).
- Toggle flags using the g / i / m / s / u buttons. Hover over any button to see what the flag does.
- Paste your test text in the textarea below. Matches are highlighted immediately with a yellow background.
- Scroll the match list to inspect each match individually, including its character index and any capture groups.
- Click Try an example to pre-fill a date-extraction pattern — a great way to see named groups in action.
Understanding Capture Groups
Capture groups let you extract sub-parts of a match. Wrap part of your pattern in parentheses to
create a group: (\d{4}) captures four digits as group 1. Add ?<name>
inside the opening paren to name the group: (?<year>\d{4}). The match list shows
each group as a labelled chip so you can verify extraction logic without writing any code.
Common Use Cases
- Extracting structured data from log lines — timestamps, HTTP status codes, request paths.
- Validating user input formats such as email addresses, phone numbers, or postal codes.
- Finding and replacing repeated patterns in a large block of text before processing it programmatically.
- Debugging a regex that works in one language but behaves differently in JavaScript (flag differences, lack of possessive quantifiers, etc.).
- Learning regex syntax interactively — try changing one part of a pattern and watch how the highlighted matches shift.
A Note on Flags
The g flag is the one most developers forget. Without it, the engine stops after
the first match — useful when you only want to check whether the pattern appears at all, but
misleading if you expect to see all occurrences. The m flag changes the meaning
of ^ and $: without it they anchor to the very start and end of the
entire string; with it they anchor to the start and end of each individual line. If your pattern
uses anchors and your text is multi-line, enabling m is almost always what you want.
Privacy
All matching is performed by the JavaScript regex engine that ships with your browser — the same
engine used by String.prototype.matchAll and RegExp.prototype.exec.
Your pattern and test text never leave your device. There is no backend, no upload, and no logging.
That makes this tool safe to use with sensitive source code, internal log files, or any other
data you'd rather not transmit over the network.
Frequently Asked Questions
What regex flavour does this tester use?↓
The tester uses the JavaScript (ECMAScript) regex engine built into your browser. This covers the vast majority of everyday regex patterns, including named capture groups (?<name>…), lookaheads, lookbehinds (in modern browsers), and Unicode property escapes. It does not support PCRE-only syntax like possessive quantifiers or atomic groups.
What do the flag buttons do?↓
g (global) finds all matches instead of stopping after the first. i makes the pattern case-insensitive. m changes ^ and $ to match the start and end of each line, not just the whole string. s (dotAll) makes the dot . match newline characters too. u enables full Unicode mode, which is required for Unicode property escapes like \p{Letter} and correct handling of surrogate pairs.
How do I use named capture groups?↓
Wrap any group with (?<name>…). For example, (?<year>\d{4})-(?<month>\d{2}) will label the two groups "year" and "month" in the match list. The tester shows each named group as a labelled chip below the matched text, making it easy to verify complex extraction patterns at a glance.
Why does my pattern match nothing even though it looks correct?↓
The most common causes are: forgetting the g flag when you expect multiple matches (without it, only the first match is returned); special characters like . ( ) [ ] that need to be escaped with a backslash when you want them literally; or anchors ^ and $ behaving differently without the m flag. Try enabling the m flag if your text has multiple lines and your pattern uses anchors.
Does this tool send my text to a server?↓
No. Every match is computed by the JavaScript regex engine running directly in your browser tab. Nothing you type — pattern, flags, or test text — ever leaves your device. This makes it safe to test patterns against sensitive data such as API keys, personal information, or private log output.