NordVPN
SponsoredStrict no-logs VPN with 6,400+ servers in 111 countries. Threat Protection blocks ads, trackers, and malware while you work online.
Get NordVPN →Type a regex and test text — matches highlight live as you type. Toggle flags (g/i/m/s/u), inspect capture groups, and preview replacements.
g (global): find all matches, not just the first. Required for replace-all behavior. i (case-insensitive): /[a-z]/i matches both cases. m (multiline): ^ and $ match at line breaks instead of only string start/end. s (dotall): . matches newlines as well. u (unicode): proper handling of code points above 0xFFFF (emoji, CJK in surrogate pairs).
Most people start with /g/i/m. /s/ becomes useful for multi-line text matching. /u/ is recommended whenever you might encounter emoji or non-BMP characters — without it, /./ won't match a 4-byte emoji as a single character.
Parentheses create a capture group: /(\d{4})-(\d{2})/ on '2026-05' captures '2026' and '05' separately. Reference them as $1, $2 in the replacement. Named groups use (?<name>...) and reference $<name> in replace.
Common replace tricks: $& inserts the full match. $1, $2 etc. insert capture groups. $$ inserts a literal $. The replace preview here lets you check before running the same pattern on a real text — much safer than running it directly on production data.
Backslash escaping. To match a literal '.', use '\.'. In a JavaScript source string this becomes '\\.' but in this tool you type just '\.' since it's the regex source.
Catastrophic backtracking. Patterns like /(a+)+/ on 'aaaa…!' can take forever. If your test seems frozen, your regex may have nested quantifiers. Simplify or use possessive/atomic groups (not available in JS regex; use careful design instead).
Greedy vs lazy. /<.+>/ on '<a><b>' matches '<a><b>' (greedy). /<.+?>/ matches '<a>' (lazy). Pick the right one for your use case.
JavaScript ECMAScript regex (the one your browser implements). It differs slightly from PCRE used in PHP, .NET, or Python.
It does in modern browsers — Chrome, Firefox, Safari, Edge all support (?<=...) and (?<!...) since 2021. If yours doesn't, your browser may be outdated.
Enables proper Unicode handling. Emoji like 🎉 (which is a surrogate pair in UTF-16) is treated as one character with /u/ but two with the default mode.
\t for tab, \n for newline, \r for carriage return, \s for any whitespace including all of these.
Most often, you forgot the 'g' flag — replace without 'g' only replaces the first match. Toggle 'g' to replace all.
Yes, up to a few MB. Beyond that, the browser may slow down. Avoid catastrophic patterns (nested quantifiers) on long input.
No. Pattern and text are processed locally only.
Search 'JavaScript regex cheat sheet'. MDN's RegExp page is the authoritative reference.
Strict no-logs VPN with 6,400+ servers in 111 countries. Threat Protection blocks ads, trackers, and malware while you work online.
Get NordVPN →Managed cloud hosting for WordPress and web apps on DigitalOcean, Vultr, and AWS. Fast setup, no server headaches.
Try Cloudways →Hire freelancers for design, writing, dev, and marketing — or sell your own services. Millions of gigs at every budget.
Browse Fiverr →