Type a replacement template to preview the rewritten text. Without the g flag only the first match is replaced, which is what String.replace does.
What this pattern says
(?<user>Start of capture group 1, named "user".[\w.]Any single character that is any word character: a letter, a digit or an underscore or ".".+Repeat the item before it one or more times, as many as possible (greedy).)End of the group.@The character "@".(?<host>Start of capture group 2, named "host".[\w.]Any single character that is any word character: a letter, a digit or an underscore or ".".+Repeat the item before it one or more times, as many as possible (greedy).\.Matches the literal ".".\wMatches any word character: a letter, a digit or an underscore.+Repeat the item before it one or more times, as many as possible (greedy).)End of the group.
Cheat sheet
Characters
- .
- Any character except a line break
- \d
- A digit, 0 to 9
- \D
- Anything that is not a digit
- \w
- A letter, digit or underscore
- \W
- Anything that is not a word character
- \s
- Whitespace: space, tab, line break
- \S
- Anything that is not whitespace
- \uFFFF
- A character by its code point
Sets and groups
- [abc]
- Any one of a, b or c
- [^abc]
- Any character except a, b or c
- [a-z]
- Any character in the range a to z
- (...)
- A numbered capture group
- (?<name>...)
- A named capture group
- (?:...)
- Group without capturing
- a|b
- Either a or b
- \1
- The text group 1 already matched
Repetition
- *
- Zero or more
- +
- One or more
- ?
- Zero or one
- {3}
- Exactly three
- {2,}
- Two or more
- {2,5}
- Between two and five
- *?
- Lazy: as few as possible
Anchors and lookaround
- ^
- Start of the text or line
- $
- End of the text or line
- \b
- A word boundary
- \B
- Not a word boundary
- (?=...)
- Lookahead: must follow
- (?!...)
- Negative lookahead: must not follow
- (?<=...)
- Lookbehind: must precede
- (?<!...)
- Negative lookbehind: must not precede
Replacement
- $1
- Capture group 1
- $<name>
- A named capture group
- $&
- The whole match
- $`
- The text before the match
- $'
- The text after the match
- $$
- A literal dollar sign
Related tools
- URLPattern TesterTest route patterns against URLs and inspect every matched group.
- Glob Pattern TesterCheck file paths against a glob pattern and see which ones match.
- XPath and CSS Selector TesterTest XPath expressions and CSS selectors against pasted HTML and see every match with its path and text.
- JSONPath QueryRun a JSONPath expression against pasted JSON and see every match and its path.
- WebAssembly Feature CheckTest which post-MVP WebAssembly proposals, like SIMD, threads, and garbage collection, your current browser actually supports.
- MCP InspectorBrowse an MCP server's tools and schemas, read its responses, and build test calls.
What it does
Runs a JavaScript regular expression against your test text and shows every match highlighted in place, so you can see what the pattern grabbed instead of guessing. Each match is listed with its offsets and its capture groups, named groups included. A replacement box previews what String.replace would produce, using the real $1, $<name>, $&, $` and $' rules. Alongside all of that, the pattern is broken down into a plain English list: which piece is an anchor, which is a character class, which is a group, and what every quantifier repeats.
How to use it
Type the pattern into the Pattern box and toggle the flags you want, then paste or type the text you are testing underneath. Matches highlight as you type and the match list fills in below, with a badge on each capture group. Add a replacement template to see the rewritten text, and open the cheat sheet at the bottom when you need to remember a token. The pattern, flags, replacement, and test text all live in the URL fragment, so a link shares the whole setup.
Why this one
The popular regex sites bury the tester under ads, ask you to sign in to save anything, or ship your pattern and your sample text to a server to be evaluated. This one runs the browser's own regex engine in your tab, so what you see is exactly what your JavaScript will do, and your files and inputs never leave your device. It is also honest about its limits: the test text is capped at 100 KB and the match list stops at 5,000 matches, so a slow pattern cannot lock up the page.
FAQ
- Which regex flavor is this?
- JavaScript, specifically the ECMAScript RegExp your browser ships. That means named groups with (?<name>...), lookbehind with (?<=...), Unicode property escapes with \p{...} under the u or v flag, and the d, g, i, m, s, u, v and y flags. Patterns written for PCRE, Python or Go mostly carry over, but a few things do not, such as possessive quantifiers, atomic groups, recursion, and inline modifiers like (?i).
- Why does my pattern only find one match?
- Without the g flag a regular expression stops at the first match, and String.replace rewrites only that one. Turn on g to scan the whole text. The y flag is different: it anchors each attempt to the position where the last match ended, so a gap in the text stops the scan.
- Can a bad pattern freeze the page?
- A pattern with nested quantifiers, the classic (a+)+b shape, can take exponential time on the right input, and no browser regex engine can be interrupted once it starts. Two guards keep that survivable rather than fatal: the test text is capped at 100 KB and the match list stops at 5,000 matches. That reduces the blast radius, it does not eliminate it, so if the tab does stall on a nested quantifier, reload and simplify the pattern.
Keyboard shortcuts: press ? anywhere on this page to see them.