About the Regex Tester
Test a regular expression against your own text and see every match as you type. Patterns run as JavaScript regular expressions. Each match is listed with its position in the text, the matches are counted, and a syntax error shows the browser's own message. That's useful when you're writing a validation rule or cleaning up data, and it's a good way to learn regex by trial.
Enter a pattern without the surrounding slashes, add flags such as g or i, and paste the text to search. The results refresh on every keystroke, so you can build a pattern a piece at a time and watch what it catches.
How the pattern is tested
Your pattern and flags become a JavaScript RegExp, exactly as new RegExp(pattern, flags) would create one in a browser or Node.js. It's the real engine, so a pattern that works here works the same way in JavaScript code, including lookbehind, named groups and Unicode property escapes in modern browsers.
With the g flag, the tester calls exec() repeatedly and lists each match with its text and its index, the zero-based position of the first matched character. Without g, only the first match is shown. A pattern that can match an empty string, such as a*, is moved forward one character after each empty match so the search always finishes.
The search runs in a background worker, separate from the page, so typing stays smooth. If it takes longer than 2 seconds, it's stopped and you're told the pattern takes too long on this text.
When the pattern or the flags aren't valid, you see the browser's error message in place of the results, for example Invalid regular expression: /(abc/g: Unterminated group.
Assumptions and limits
- This is JavaScript regex. Most syntax is shared with PCRE, Python and Java, but some isn't: possessive quantifiers like a++ and an inline modifier like (?i) at the start of a pattern are errors here.
- The flags box accepts any JavaScript flags (g, i, m, s, u, v, y, d). An unknown letter or a repeated flag is reported as an error.
- Each match is shown as a whole. Capture groups are not listed separately, and matches are listed rather than highlighted inside the text.
- Type backslashes once: \d, not \\d. The pattern box takes a raw pattern, not a quoted string.
- A pattern with catastrophic backtracking, such as (a+)+$ against a long run of a's followed by b, is stopped after 2 seconds instead of freezing the tab. That's a sign the pattern needs rewriting, because the same pattern would hang in your own code too.
- The match count includes every match, but only the first 1,000 are listed, which keeps the page quick when a pattern matches almost everything.
Worked examples
Match email addresses (the sample)
The starting pattern finds three addresses in the sample text. The index tells you where each one starts, counting from 0.
Pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} Flags: g
Match #1: "support@stratigo.digital" (at index 14)
Match #2: "sales@company.org" (at index 42)
Match #3: "john.doe123@domain.co.uk" (at index 85)Find dates in a log file
With \d{4}-\d{2}-\d{2} and the g flag, the text "Started 2026-01-05, failed 2026-01-07" gives two matches. Remove the g and only the first date is listed.
Match #1: "2026-01-05" (at index 8) Match #2: "2026-01-07" (at index 27)
Case-insensitive regex test with the i flag
With flags g, the pattern error finds nothing in "ERROR: disk full. Error again.". Change the flags to gi and both ERROR and Error match.
Regex flags you can use
| Flag | Name | What it changes |
|---|---|---|
| g | Global | Finds every match instead of stopping at the first |
| i | Ignore case | A matches a, and a matches A |
| m | Multiline | ^ and $ match at the start and end of each line |
| s | Dot all | . also matches line breaks |
| u | Unicode | Treats emoji as one character and allows \p{L} and similar |
| y | Sticky | Matches only at the current position (lastIndex) |
How to use the Regex Tester
- Type the pattern. In the box between the slashes, without the slashes themselves.
- Set the flags. g lists every match; add i, m, s or u as needed.
- Paste test text. Match Diagnostics updates live with the count, each match and its index.
Frequently asked questions
Which regex flavour does this tester use?
JavaScript (ECMAScript), run by your browser's own engine. Results match what you'd get from String.match, RegExp.exec or replace in JavaScript. For PHP, Python or Java, most everyday patterns behave the same, but check advanced features in that language.
Why does my regex find only one match?
Because the g (global) flag is missing. Without it, a JavaScript regular expression stops after the first match. Type g in the flags box and every match in the text is listed with its own index.
How do I match a dot, bracket or other special character?
Put a backslash before it: \. matches a full stop, \( an opening bracket and \$ a dollar sign. Without the backslash, . means any character, which is why an unescaped example.com pattern also matches examplexcom.
What does the index next to each match mean?
It's the position where the match starts, counting from 0 at the first character of the test text. Line breaks count as one character each, so the index matches what JavaScript's match.index returns.
How can I test a regex across multiple lines?
Add the m flag, so ^ and $ match at the start and end of each line. For example, ^ERROR.*$ with gm lists every line starting with ERROR. Add s if you need . to cross line breaks as well.
This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.