Toolify

Regex Tester (live matches, groups, replace)

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.

Flags
Matches (4)
Hello World, this is a Regex Tester.

How it works

What flags do

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.

Capture groups and replace

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.

Pitfalls to watch for

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.

Frequently asked questions

Which regex flavor does this use?

JavaScript ECMAScript regex (the one your browser implements). It differs slightly from PCRE used in PHP, .NET, or Python.

Why doesn't lookbehind work?

It does in modern browsers — Chrome, Firefox, Safari, Edge all support (?<=...) and (?<!...) since 2021. If yours doesn't, your browser may be outdated.

What does the 'u' flag do?

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.

How do I match a tab or newline?

\t for tab, \n for newline, \r for carriage return, \s for any whitespace including all of these.

Why is my replace not working?

Most often, you forgot the 'g' flag — replace without 'g' only replaces the first match. Toggle 'g' to replace all.

Can I use this for very long text?

Yes, up to a few MB. Beyond that, the browser may slow down. Avoid catastrophic patterns (nested quantifiers) on long input.

Does the data leave my browser?

No. Pattern and text are processed locally only.

Is there a regex cheat sheet?

Search 'JavaScript regex cheat sheet'. MDN's RegExp page is the authoritative reference.

Related tools

Last updated: