Online Regex Tester
Debug patterns in seconds instead of Stack Overflow threads. This free online regex tester checks your JavaScript regular expression as you type, highlights every match in your test text, counts them, and shows what each capture group grabbed. Invalid patterns get a plain-language error message pointing at the problem — no cryptic console output required. Everything runs locally in your browser.
Test a Regular Expression
How to Use the Online Regex Tester
Three inputs, instant answers:
- Type your pattern into the pattern box — no slashes or delimiters needed, just the raw expression like
\d{3}-\d{4}. It is checked the moment you type: a valid pattern shows matches, a broken one shows a plain-language explanation of what went wrong. - Toggle the flags you need.
g(find all matches, not just the first) is on by default. Addifor case-insensitive matching,mwhen^and$should work per line,swhen you want.to cross line breaks,ufor proper Unicode handling, oryfor sticky matching. - Paste your test text and read the results. Every match is highlighted in yellow, the big number tells you how many were found, and the match-details list shows the position of each hit plus exactly what every capture group captured. The Email, URL, and US Phone preset buttons drop in battle-tested patterns so you can experiment immediately.
A handy debugging trick: build patterns incrementally. Start with the simplest version that matches something (\d+ for "some digits"), confirm it highlights, then add one piece at a time — a group here, a quantifier there. When the highlights suddenly vanish, the last piece you added is the culprit. The tester makes this loop nearly instant because every keystroke re-runs the match.
How Regex Matching Works Here
This tester uses your browser's built-in JavaScript regex engine — the exact same RegExp that runs in Node.js, Chrome, and every modern browser — so a pattern that works here works in your JavaScript code verbatim. The pattern compiles with new RegExp(pattern, flags); if compilation throws, you get the error message translated into actionable advice instead of a stack trace.
Matching itself scans left to right through your text. With the g flag, the engine finds every non-overlapping match; without it, you would only ever see the first. Each match records its starting position and the contents of every capture group — the parts of the pattern wrapped in parentheses. In the email pattern ([A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+\.[A-Za-z]{2,}), group 1 captures the username and group 2 captures the domain, which is exactly what the match-details list shows you.
A few engine behaviors worth knowing: . does not match line breaks unless the s flag is on; ^ and $ anchor to the start and end of the whole text unless m makes them per-line; and quantifiers like * and + are greedy by default, grabbing as much as possible — add a ? after them (.*?) to make them lazy. The u flag switches the engine to Unicode mode, which fixes emoji and astral characters but also makes invalid escapes an error, so only enable it when you need it.
Worked Example
Say you need to pull every email address out of a block of text. Click the Email preset (or type the pattern yourself) and watch it work on the sample text:
| Step | What happens | Result |
|---|---|---|
| 1. Pattern | \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b | Compiles cleanly — no error |
| 2. Flags | g (global) | Finds all addresses, not just the first |
| 3. Match 1 | support@example.com | Found at position 14 |
| 4. Match 2 | sales@toolnest.io | Found at position 36 |
| 5. Match 3 | jane.doe+filter@mail-server.co.uk | Found at position 218 — dots, plus-tags and multi-part domains all match |
Three matches, each highlighted in the text. Notice the pattern deliberately rejects things that merely look email-ish: the \b word boundaries and the required @ plus top-level domain keep it honest. If you need the username and domain separately, wrap them in groups — ([A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+\.[A-Za-z]{2,}) — and the match details will list Group 1 and Group 2 for every hit.
Limitations
This tester implements the JavaScript (ECMAScript) regex flavor. Patterns written for Python, PCRE/PHP, .NET, or Java will mostly work, but flavor-specific features will not: no lookbehind in very old browsers (modern ones support it), no (?P<name>) named-group syntax from Python (JavaScript uses (?<name>)), no atomic groups or possessive quantifiers from PCRE, and no \p{...} Unicode properties without the u flag.
Performance is also real: catastrophic backtracking (nested quantifiers like (a+)+$ on long input) can freeze the tab, because the browser runs the match on the main thread. The tester caps scanning at 1,000 matches as a safety net, but a pathological pattern on a huge text can still hang — keep test inputs modest while experimenting. Finally, regex validates format, not reality: a pattern can confirm that user@example.com looks like an email, but it cannot tell you whether the mailbox exists.
Regular expressions search text; they can't tell you whether the text is valid. For the JSON half of the workflow, our guide to formatting JSON explains validation, pretty-printing and the errors parsers actually report.
Guides for This Tool
Frequently Asked Questions
How do I test a regular expression online?
What do the regex flags g, i, m, s, u and y do?
Why is my regex invalid, and how do I fix it?
What are capture groups in regex?
Why does my pattern find no matches?
Is my test text uploaded to a server?
Related Tools
URL Encoder / Decoder
Encode URLs and components, decode percent-encoding.
Base64 Encoder / Decoder
Convert text to Base64 and back with full Unicode support.
JWT Decoder
Decode JSON Web Tokens and inspect expiry dates.
JSON Formatter
Format, validate, and minify JSON with syntax highlighting.
Cron Expression Generator
Build cron schedules visually with plain-English descriptions.
UUID Generator Online Free
Generate bulk v1 and v4 UUIDs instantly with per-line copy — free, private, in your browser.