Test regular expressions against sample text with live highlighting, match details, capture groups and replace.
//
🔒 This tool runs entirely in your browser. Nothing you enter or upload is sent to our servers.
How to use the Regex Tester
- Type your pattern (without slashes) and choose flags — g for all matches, i for case-insensitive, m for multiline.
- Paste test text; matches are highlighted and listed with their capture groups as you type.
- Enter a replacement (use $1, $2 for groups) to preview the result of replace().
About this tool
This tester uses your browser’s JavaScript regex engine, so behaviour matches Node.js and browsers exactly (including lookbehind, named groups and Unicode property escapes). Other engines (PCRE, Python, Java) are very similar for everyday patterns.
Quick reference
. | any character except newline | \d \w \s | digit, word char, whitespace |
* + ? | 0+, 1+, 0–1 times | {n,m} | between n and m times |
^ $ | start / end of line (with m flag) | \b | word boundary |
[abc] [^abc] | character set / negated set | (a|b) | group with alternation |
(?:…) | non-capturing group | (?<name>…) | named group |
(?=…) (?!…) | lookahead / negative lookahead | (?<=…) (?<!…) | lookbehind / negative |
Frequently asked questions
Why does my regex only find the first match?
Add the g (global) flag. Without it, JavaScript stops after the first match.
How do I match across multiple lines?
Use the s flag so that . also matches newlines, and the m flag so ^ and $ work per line.
How do I reference a capture group in the replacement?
Use $1, $2… for numbered groups or $