██████╗ ███████╗ ██████╗ ███████╗██╗ ██╗ ████████╗███████╗███████╗████████╗███████╗██████╗ ██╔══██╗██╔════╝██╔════╝ ██╔════╝╚██╗██╔╝ ╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝██╔════╝██╔══██╗ ██████╔╝█████╗ ██║ ███╗█████╗ ╚███╔╝ ██║ █████╗ ███████╗ ██║ █████╗ ██████╔╝ ██╔══██╗██╔══╝ ██║ ██║██╔══╝ ██╔██╗ ██║ ██╔══╝ ╚════██║ ██║ ██╔══╝ ██╔══██╗ ██║ ██║███████╗╚██████╔╝███████╗██╔╝ ██╗ ██║ ███████╗███████║ ██║ ███████╗██║ ██║ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
Regex Tester — Test Regular Expressions Live With Capture Groups
Guide — write, see and fix a regex
Write it between the slashes, or pick one from Patterns or the cheat sheet. The dot turns red if the syntax is invalid.
g all matches, i ignore case, m ^ and $ per line, s dot matches newlines, u Unicode.
The pattern diagram draws your regex as railroad tracks: boxes are what must match, loops repeat, bypasses are optional.
Each capture group gets its own colour. Step with Prev / Next (F3); the details panel lists every group with its position.
Preview a replacement with $1 or $<name>, copy the regex as JavaScript, Python, PHP, Java, Go or Ruby, or share a link.
Which panel answers which question
- output
- every match highlighted, groups coloured
- counters
- matches, groups, chars, time
- details
- each group with index and line:col
- diagram
- railroad view of the structure
- Explain
- token-by-token in plain English
- warning
- nested repeats flagged up front
- worker
- matching runs with a hard timeout
- replace
- live preview, copy the result
- code
- JS, Python, PHP, Java, Go, Ruby
- link
- pattern, flags and text in the URL
How to test a regular expression — and read what it does
What a regex tester is actually for
Writing a regular expression is guesswork until you can see what it matches. Type a pattern
here and every match lights up in your test string as you type, with each capture group in its
own colour, so you find out immediately that \d+ also matched the year in the
footer and that your email pattern accepts a@b.
The four counters at the top are the quickest sanity check there is. Matches tells you whether the pattern fires at all, groups whether your parentheses captured what you meant, chars matched whether a lazy quantifier should have been greedy, and exec time whether the pattern is about to become a problem.
Flags change the answer more than the pattern does
Most confusing results are a flag, not a syntax error. Without g you get the first
match and nothing else. Without m, ^ and $ anchor to the
whole string rather than each line, which is why a pattern that works on one line finds nothing in
a paragraph. s lets . cross newlines. u is what makes
\p{...} property escapes legal at all. Toggle them and watch the highlighting move.
Everything runs in this tab
The pattern, the test string and the replacement are matched by your own browser's
RegExp engine. Nothing is uploaded, there is no account, and the share link carries
your regex in the URL rather than storing it on a server. That also means the flavour you are
testing is JavaScript's — close to PCRE for everyday work, but not identical to Python, Go or
.NET, so check the flavour before pasting a pattern somewhere else.
Reading the railroad diagram
A railroad (syntax) diagram shows a regex as a track you follow from the dot on the left to the dot on the right. Every route you can take spells a string the pattern accepts. Green boxes are literal text, cyan boxes are character classes such as [a-z], purple ones are shorthands such as \d or ., and orange ones are positions that match no characters: ^, $ and \b.
A track that splits into several lanes is an alternation (a|b): pick one lane. A track that bends over a box means the box can be skipped (?, *, {0,n}); a loop under a box means it can repeat (+, *, {2,5}), with the count written under the loop. Dashed yellow frames are capture groups, numbered the way $1, $2 number them; orange frames are lookarounds, which check what comes before or after without consuming it. For (\w+)@([\w.-]+) you see group #1 with a loop around "word char", a green "@", then group #2 looping over "one of \w.-".
Flavour and flags
Which regex flavour is used?
JavaScript (ECMAScript) regular expressions. This is the same engine used in modern browsers, Node.js, Deno, and Bun. Named groups, lookbehinds, and Unicode property escapes are supported.
Can I use flags like global or case-insensitive?
Toggle the g (global), i (case-insensitive), m (multiline), s (dotAll), and u (unicode) flags with the buttons above the pattern input. The regex is re-evaluated instantly.
What does the g flag actually change?
Without g, JavaScript stops after the first match. With g toggled on, this tool finds every match in the test string and lists them all in the details table. Turning g off is useful when you only care whether a pattern matches at all, or want to inspect the very first match closely.
Groups and syntax
How do capture groups work?
Wrap part of your pattern in parentheses () to create a capture group. The match details table below the output shows each group's value and index. Groups are colour-coded in the output.
What's the difference between capturing and non-capturing groups?
Parentheses (...) create a capturing group — its match is numbered ($1, $2...) and shows up in the details table. Prefix with ?: — (?:...) — for a non-capturing group: it still groups the pattern for quantifiers or alternation, but doesn't produce a numbered result. Use non-capturing groups to keep your group numbering clean when you don't need a piece of text back.
Can I name my capture groups, and use the names in a replacement?
Write (?<name>...) to create a named group — its value appears alongside the numbered groups in the match details table. In the replacement field, reference it with $<name> instead of $1, $2, etc.
What's the difference between greedy and lazy quantifiers?
A greedy quantifier like *, +, or {2,5} matches as much as it possibly can, then backtracks only if needed. Adding a ? — *?, +?, {2,5}? — makes it lazy, matching as little as possible instead. Click Explain above the pattern input to see each quantifier in your own pattern labelled greedy or lazy.
What is a word boundary (\b), and when should I use it?
\b matches the invisible position between a word character (letter, digit, underscore) and a non-word character — without consuming any text itself. It's what makes \bcat\b match the whole word "cat" but not "category" or "scatter". Use \B for the opposite: a position that is not a word boundary.
How do I match a literal special character like . or *?
Escape it with a backslash: \. matches a literal period, \* a literal asterisk, and so on for \ ^ $ . | ? * + ( ) [ ] { }. Inside a character class ([...]) most of these lose their special meaning already, so [.] is equivalent to \..
Do you support Unicode property escapes like \p{Emoji}?
Toggle the u (unicode) flag, then patterns like \p{Letter}, \p{Script=Greek}, or \p{Emoji} work as in any modern JavaScript engine. Without the u flag, \p{...} is treated as a literal, not a Unicode property escape.
Replacements, explain mode, history and sharing
Can I test replacements?
Type a replacement string in the replacement input below the pattern. Use $1, $2 etc. to reference capture groups, or $& for the full match. The replaced output appears live.
Can it explain what my regex means?
Click Explain above the pattern input for a plain-English, line-by-line breakdown of every anchor, character class, quantifier, group, and lookaround in your pattern — handy for untangling a pattern someone else wrote.
What happens if my regex is slow or catastrophic?
Matching runs off the main thread in a Web Worker with a hard timeout, so a runaway pattern can't freeze the page. Patterns with tell-tale signs of catastrophic backtracking (nested repeating groups) get a warning up front, and anything that takes too long is aborted automatically.
Does it remember my previous patterns?
Open the History tab to see recently tested patterns, saved only in your browser's local storage. Click one to restore its pattern, flags, and test string, or clear the list anytime.
Can I export my regex as code?
Choose a language — JavaScript, Python, PHP, Java, Go, or Ruby — from the dropdown below the match output and click Copy as code to get a ready-to-paste snippet using that language's native regex syntax.
Can I jump between matches or see line/column positions?
Use the Prev/Next buttons (or F3 / Shift+F3) above the match output to step through matches one at a time — the current match is outlined in the highlighted text. The match details table also shows each match's line and column position, not just its character index.
Can I share my regex or link directly to one?
Click the Share link button to copy a URL that encodes your pattern, flags, and test string — and the address bar stays in sync as you edit. You (or an AI assistant) can also build a deep link by hand: ?pattern=\d+&flags=g&test=abc123. Supported parameters are pattern (alias regex/r), flags (f), test (input/t), and replace (replacement/rep). Anyone who opens the link sees the same setup.
Is there a keyboard shortcut to run the match?
The pattern re-evaluates automatically as you type (lightly debounced). If you want to force an immediate re-match, press Ctrl+Enter (or Cmd+Enter on Mac). Use F3 / Shift+F3 to jump to the next or previous match.
Troubleshooting and other languages
Why doesn't my regex match across multiple lines?
By default, . does not match newline characters, and ^/$ only match the very start/end of the whole string. Toggle the s (dotAll) flag so . also matches newlines, or the m (multiline) flag so ^/$ match the start/end of each line instead.
Is this a good way to validate emails or passwords?
It's a great way to prototype and test the pattern, but be cautious about using it as a real-world validator: a fully RFC-compliant email regex is notoriously complex, and password rules are usually better expressed as several small checks (length, character classes) than one giant pattern. Always validate again on the server — client-side regex checks can be bypassed entirely.
Does JavaScript regex work the same as Python or PCRE regex?
Mostly, but not identically. JavaScript lacks some PCRE features (possessive quantifiers, recursive patterns, inline verbose/comment mode) and has its own flag system (g, u, d, etc). Named groups, lookaheads and lookbehinds, and most character classes behave the same way. When porting a pattern from another language, re-test it here rather than assuming it will behave identically.
Does this work the same in every browser?
This tool relies only on the standard JavaScript RegExp engine and Web Worker API, both supported in all current versions of Chrome, Firefox, Safari, and Edge. Very old browsers may not support newer syntax like named groups, lookbehinds, or \p{...} property escapes even if the tool itself loads fine.
Privacy
The pattern, the test string and the replacement are matched by your own browser's RegExp engine, in a Web Worker started from the page itself. Nothing is uploaded and there is no account. History is kept in this browser's local storage, and a share link carries the regex in the URL rather than on a server.
More developer tools
Use your pattern on real files. The free online notepad has Notepad++-style find & replace with regular expressions and $1 capture groups, in one file or across every open tab — nothing to install.