Like ToolFern? Prefer us as your source on Google →

Find and Replace Text

Swap one string for another across a whole block of text, with case-insensitive matching, whole word matching and full regular expression support. The result updates as you type, and you can stack several find and replace rules so one pass handles a whole cleanup list.

How to find and replace text

  1. Paste or type your content into the Your text box.
  2. Put what you are looking for in the Find box and what should take its place in Replace with.
  3. Tick Case insensitive to ignore capitals, Whole word only to skip matches sitting inside a longer word, or Use regex to treat the Find box as a pattern.
  4. Click + Add rule for a second find/replace pair. Each rule carries its own three toggles.
  5. Read the count under the buttons. It reports how many matches were swapped, added up across every rule.
  6. Press Copy to lift the result onto your clipboard.

The Replace all button is there if you want it, but the tool already re-runs on every keystroke and every toggle, so the Result box is usually filled in before you reach for it. Your original stays in the input box untouched, which means you can keep tweaking the pattern and watching the count move.

Literal search versus regular expressions

With Use regex off, your search text is matched exactly as typed. Dots, brackets, dollar signs and question marks are escaped for you behind the scenes, so searching for www.example.com finds that literal address rather than treating the dots as wildcards.

Turn the toggle on and the Find box becomes a JavaScript regular expression. That buys you \d+ for runs of digits, \s+ for stretches of whitespace, character classes like [A-Za-z], alternation with the pipe, and capture groups you can reference in the replacement as $1,$2 and so on. If the pattern will not compile, the tool catches the error and prints the reason, naming the rule number when more than one rule is in play, and leaves your text alone.

One limit worth knowing before you write anchors: the pattern is compiled with the global flag and, if you ticked the case box, the ignore-case flag. There is no multiline flag. In JavaScript that means ^ matches the very start of the whole text and $ matches the very end, not the start and end of each line. To act on line starts, match the newline directly with \n in your pattern instead.

Why "Whole word only" ignores accents

This is the one that catches people out, and it is not a bug in the tool. Whole word only wraps your pattern in \b word boundary assertions, and JavaScript defines a word character as ASCII only: the ranges A to Z, a to z, 0 to 9, plus _.MDN's word boundary referencespells the set out. Nothing outside those 63 characters counts.

Two consequences follow.

Search for café with Whole word only ticked and you will get zero matches, because the é on the end is not a word character, so no boundary exists after it. The same goes fornaïve, Ångström, Zürich and every Cyrillic, Greek or CJK word you might try. Turn the toggle off and the identical search works fine.

Now flip it round. Because _ does count as a word character, searching for cat with whole-word matching on will not touch cat_dog or hot_cat, even though most people reading that code would call cat a separate word there. If you are renaming a variable in a snake_case codebase, leave the toggle off and use regex mode with an explicit boundary of your own, such as(^|[^a-z])cat([^a-z]|$).

The dollar sign trap in the Replace box

Whatever you type into Replace with is handed straight to JavaScript's string replace, and that function reserves $ for substitution patterns no matter which mode you are in. $&inserts the whole matched text, $` inserts everything before the match, $' inserts everything after it, and $1 through $99 insert capture groups.MDN documents the full list.

So if you want a literal dollar sign in the output, type $$. Replacing USD with$ will not do what you expect on its own. Replacing it with $$ gives you a single$ per match. This applies with Use regex switched off too, because the tool still builds a regular expression internally after escaping your find text. That same rule is useful in reverse: to wrap every number in brackets, switch to regex mode, find \d+ and replace with ($&), with no capture groups needed.

Chaining rules for a cleanup pipeline

Real tidying jobs rarely stop at one swap. You strip a template placeholder, fix a misspelt product name, collapse the double spaces the first two edits left behind, then normalise a date format. Click+ Add rule for each step. Rules run top to bottom and each one works on the output of the one before it, so rule three genuinely sees rule two's handiwork rather than the original paste. A numbered header and a remove button appear on each row once you have more than one, and the last remaining rule cannot be deleted. Rules with an empty Find box are skipped rather than throwing an error, so a half-built row will not block the rest of the chain.

Order matters more than it looks. If rule one turns every and into & and rule two searches for and, rule two finds nothing.

Reading the replacement count

The number under the buttons is a cheap sanity check. Expected to fix one stray word and the tool says 47 replacements? Your pattern is too broad, and you have found that out before pasting the result anywhere that matters.

Be aware of what the count actually measures. It tallies matches per rule at the moment that rule runs, then adds the totals. If an earlier rule creates text that a later rule matches, those later matches are counted too, so the figure can exceed the number of distinct spots in your original text.

The replacement itself is done by a script in the page, and the text you paste is not sent to ToolFern.

Frequently asked questions

Why does "Whole word only" miss words with accents?

JavaScript's \b boundary treats only A to Z, a to z, 0 to 9 and the underscore as word characters, so an accented letter such as the é in café ends the word as far as the engine is concerned and no boundary is found after it. Untick the box and the search works.

How do I put a literal dollar sign in the Replace with box?

Type $$. A single $ starts a substitution pattern, so it gets eaten.

Do ^ and $ match the start and end of each line?

No. The pattern is compiled without the multiline flag, so ^ anchors to the start of the entire text and $ to its end. Match \n explicitly if you need line breaks.

Can I use capture groups in the replacement?

Yes. Tick Use regex, wrap part of your pattern in parentheses, then reference the groups as $1, $2 and so on in the Replace with box. $& gives you the whole match without needing a group at all.

Does it replace every match, or just the first one?

Every match, in one go. There is no step-through-the-matches mode, which is why the count and the untouched original in the input box matter: you check the number, adjust the pattern, and run again.

What happens when several rules are in the list?

They run in order from top to bottom, each one taking the previous rule's output as its input. That lets you build a small pipeline, but it also means a rule can hide matches from the rules below it, so put the broadest change last.

Related: clean up messy text · change text case · count words & characters

Found this useful? Share it