Dev

Regex Replace

Pattern

Set find and replace patterns with regex flags.

Find (regex)
Replace with
Flags3 matches

Use capture groups like $1, $2 in replacement text.

Input

Paste source text to transform with your regex.

Result

The quick brown cat jumps over the lazy dog.
cat and cat are different.

Frequently Asked Questions

Can I use capture groups in the replacement string?
Yes. Use $1, $2, etc. to reference capture groups in the replacement. For example, pattern (\w+)\s(\w+) with replacement $2 $1 swaps the first two words. Named groups can be referenced with $<name> in modern JavaScript regex.
How do I replace all occurrences, not just the first?
Enable the g (global) flag. Without g, only the first match is replaced. With g, all non-overlapping matches throughout the text are replaced. Using replaceAll() equivalent is what the g flag enables.
What special characters need escaping in the pattern?
These characters have special meaning and must be escaped with \ when you want to match them literally: . * + ? ^ $ { } [ ] | ( ) \. For example, to match a literal dot, use \. instead of . (which matches any character).