What This Tool Does

This find and replace tool searches any text for a target string or regex pattern and replaces it with a new string. Options include case-sensitivity, whole-word matching, regex mode, and match counting. Useful for cleaning data, refactoring content, or bulk editing documents.

Inputs Explained

How It Works

The tool builds a JavaScript RegExp from your input (escaping special characters if regex mode is off), applies appropriate flags (g for global, i for case-insensitive), and uses String.replace to perform the substitution. It also counts matches before replacing so you can preview the change count.

Formula / Logic Used

plain: new RegExp(escape(find), flags) regex: new RegExp(find, flags) word: new RegExp('\\b' + escape(find) + '\\b', flags)

Find and Replace Text (with Regex)

Find and replace text instantly with regex, case, and whole-word options.

Step-by-Step Example

Source: The cat sat on the mat. Another cat was there too.

Find: cat | Replace: dog | Whole word:

Result: The dog sat on the mat. Another dog was there too.

Regex example: Find (\d{4})-(\d{2})-(\d{2}), Replace $3/$2/$1 converts YYYY-MM-DD dates into DD/MM/YYYY format across the entire text.

Use Cases

Assumptions and Limitations

Disclaimer: Test your find pattern on a small sample before applying to critical data. Replacements cannot be undone within the tool.

Frequently Asked Questions

How do I use regex in the find field?

Check 'Regex mode' and enter the pattern without surrounding slashes. For example, to match any 4-digit year, use \d{4}. To match an email, use [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.

What are capture groups?

Parentheses in a regex capture matched text into groups you can refer to in the replacement as $1, $2, etc. Example: Find (\w+) (\w+), Replace $2 $1 — this swaps every pair of words.

What's the difference between whole-word and case-sensitive?

Case sensitive matches only when uppercase/lowercase match exactly. Whole-word matches only when the search term is surrounded by word boundaries (punctuation, spaces) — 'cat' won't match 'category'.

Why isn't my regex matching anything?

Common causes: you included slashes (remove them), used Python syntax (like named groups with ?P — use ? instead), or escaped a character that didn't need escaping. Test the pattern with 'Count Matches' first.

Is the replacement reversible?

No — once you click Replace All, the new text appears in the result. Your original text remains in the input box, so you can copy it back and try again with different find/replace values.

Can I use multi-line regex?

JavaScript regex doesn't have a standard multi-line mode flag here, but \n matches newlines within the text. For multi-line patterns, use (.|\n) instead of . to match across lines.

How do I replace special characters like newlines or tabs?

In regex mode, use \n for newline and \t for tab. In the replacement field, \n and \t also work. Example: replace \n with | to convert a list to comma-separated (pipe-separated).

Is my text stored anywhere?

No. All processing runs entirely in your browser. Source text and regex patterns never leave your device.

Sources and References

Related Calculators

Remove Duplicate LinesSort LinesCase ConverterWhitespace RemoverEmail ExtractorReverse Text