Free online tools to generate, calculate,
convert, format, encode, and play.
 

Find & Replace with Regex

Advanced find and replace with full regular expression support including capture groups, backreferences, and live match preview.



Quick reference

.Any character (except newline without s flag)
\d \DDigit / Non-digit
\w \WWord character / Non-word character
\s \SWhitespace / Non-whitespace
\b \BWord boundary / Non-word boundary
[abc]Character class (a, b, or c)
[^abc]Negated character class
a|bAlternation (a or b)
(abc)Capture group → use $1 in replacement
(?:abc)Non-capturing group
(?<name>abc)Named capture group → use $<name>
(?=abc) (?!abc)Lookahead / Negative lookahead
(?<=abc) (?<!abc)Lookbehind / Negative lookbehind
* + ?0+, 1+, 0 or 1 (greedy)
*? +? ??Lazy quantifiers
{n} {n,} {n,m}Exact, at least, range
^ $Start / End of string (or line with m flag)
$1 $2 $&Replacement: capture group, whole match

How it works

This tool uses JavaScript's built-in regular expression engine to find and replace patterns in your text. The pattern and replacement are applied in real time as you type.

  • Regex pattern: enter any valid JavaScript regular expression. Special characters like ., *, +, (, ) have special meaning. To match them literally, escape with a backslash (e.g. \.).
  • Replacement: use $1, $2, etc. to reference capture groups, $& for the entire match, $` for text before the match, and $' for text after the match.
  • Flags: Global (g) replaces all matches instead of just the first. Case insensitive (i) ignores letter case. Multiline (m) makes ^ and $ match line boundaries. Dotall (s) makes . match newline characters.
  • Match Preview: shows your text with all matches highlighted in real time. The match count is displayed on the tab label.
  • Replaced Output: shows the final text after all replacements are applied.

Embed This Util

You can embed this util on your own site as a widget. Adding ?embed=1 to the URL loads a compact version with just the tool itself; no header, menu, or documentation. Paste this snippet into your HTML:


    

Copy snippet Adjust the height to taste.



Feedback

Help us improve this page by providing feedback, and include your name/email if you want us to reach back. Thank you in advance.


Share with