ToolForge
Advertisement

Find and Replace

Search and replace text, with regex and highlighting

Written by toolforge.websiteLast reviewed How we build and check these tools

Find and Replace tool

0 replacements.

Text
0 characters · 0 lines

Find and replace

0 replacements

How to match

Stops "art" from rewriting "start" and "chart".

CAT becomes DOG, Cat becomes Dog, cat becomes dog.

The only way to search for or insert a line break from a single-line field.

Ready-made replacements

Picking one replaces your current rules and switches on the options it needs, so you can see exactly what pattern does the work.

Result

0 lines changed

Find and Replace: key facts

What it does
Search and replace text, with regex and highlighting
Category
Text Tools
Cost
Free, with no account, sign-up, or install.
Your data
Runs entirely in your browser — the files and text you enter are never uploaded to a server.
Last reviewed
. Report an incorrect result.
Advertisement

What this tool is for

Swapping one string for another across a wall of text — renaming a variable in a snippet, updating a product name through a draft, normalising a column of scraped data — is the job find and replace exists for. What usually goes wrong is not the swap itself but not being able to see what it is about to touch. This tool highlights every match in the text as you type the search term, so the count and the damage are visible before you copy anything out.

Plain-text mode matches exactly what you type and inserts your replacement exactly as typed, dollar signs and backslashes included. Regex mode gives you the rest: character classes, quantifiers, capture groups you can reorder with $1 and $2, named groups, and the flags that actually matter in a replace tool. Line anchors are on by default, so a pattern beginning with ^ applies to every line rather than only the first — the single most common thing people want from regex here and the thing most simple tools get wrong.

Two options cut down on collateral damage. Whole words only stops a short search term rewriting the insides of longer words, and it works in plain-text mode, so you do not have to learn word-boundary syntax to get the safe behaviour. Preserve the original case gives each replacement the casing of the text it replaced: searching case-insensitively for "cat" turns CAT into DOG, Cat into Dog and cat into dog in one pass, instead of flattening all three.

Bigger jobs need more than one rule. Add as many as you need and they run top to bottom, each over the output of the one before it, with its own replacement count next to it — which also makes the ordering trap visible, since a later rule can match text an earlier one produced. You can step through a single occurrence at a time, feed the result back into the input for another pass, undo anything, restrict the work to lines containing a particular string, and load or save the text as a file. It all runs in your browser.

How to use the Find and Replace

  1. Paste your text into the top box, or drop a .txt, .md or .csv file onto it.
  2. Type what to find and what to replace it with — matches highlight in the text above as you type, with a running count.
  3. Pick plain text or regular expression, and tick Match case, Whole words only or Preserve the original case as the job needs.
  4. Add more rules if one pass is not enough; they run in the order shown and each reports its own count.
  5. Copy or download the result, or press Apply to text to run a further pass over what you just produced.

Plain text, patterns, and the dollar sign problem

In plain-text mode your search term is escaped for you, so a dot matches a dot and a bracket matches a bracket. Less obviously, the replacement is inserted verbatim too. That matters because a dollar sign has a special meaning in JavaScript replacements — $& means the matched text, $$ means one dollar — and a tool that hands your replacement straight to the language will quietly mangle a price, a shell variable or a LaTeX fragment. Here plain text means plain text in both fields.

Switch to regular expressions and those references come back deliberately: $1 and $2 for capture groups, $<name> for a named one, $& for the whole match. That is how a reformat happens in one pass — capturing the parts of a date and writing them back in a different order rather than replacing anything at all.

Because both fields are single-line, escape sequences fill the gap. Typing \n in either field means a real line break, and \t a tab, which is what makes "put each comma-separated item on its own line" a single replacement rather than an impossibility. Switch that reading off if you genuinely need a backslash followed by an n.

  • Plain text: replacing "cost" with "US$50" inserts exactly US$50.
  • Regex: (\d{4})-(\d{2})-(\d{2}) replaced with $3/$2/$1 turns 2026-08-29 into 29/08/2026.
  • Replacing \s*,\s* with \n breaks a comma list onto separate lines.

What the Find and Replace gets right

  • Matches are highlighted in the text itself as you type the search term, so you can see what a replacement will touch instead of inferring it from a count.
  • Plain-text mode inserts your replacement exactly as typed — a dollar sign stays a dollar sign, which most replace tools get wrong because they hand the string straight to the language.
  • Whole words only works without switching to regex, so the safe behaviour for a short search term does not require learning word-boundary syntax.
  • Preserve the original case gives each replacement the casing of what it replaced, so a case-insensitive pass does not flatten CAT, Cat and cat into one form.
  • Line anchors are on by default, which makes a pattern starting with ^ apply to every line rather than only the first — usually the whole reason for reaching for a pattern here.
  • Several rules run in order with their own counts, and you can replace one occurrence at a time, feed the result back for another pass, or undo — a global replace is no longer all or nothing.
  • Everything runs locally in your browser using JavaScript's own RegExp engine, so nothing is uploaded.

The mistakes that make a mess

Substring matching is the usual cause of damage. Replacing a short word without word boundaries also rewrites it inside longer words, so replacing "art" quietly changes "start", "particle" and "chart". Ticking Whole words only is the fix, and unlike the regex-only advice most tools offer, it works while you stay in plain-text mode. The highlighted matches make the problem obvious anyway: if four things light up when you expected one, the search term is wrong.

Order matters once you have more than one rule. If a later rule can match what an earlier one produced, the two interact and the result depends on sequence — replacing A with B and then B with C turns the original A into C, which is rarely what anyone wanted. The rules list numbers each step and shows its own count, so an unexpected number tells you where the collision is. Using a placeholder unlikely to occur naturally as an intermediate step avoids it entirely.

Two smaller traps. A pattern that can match nothing — x* or \s* on its own — matches the empty string between every character, so the replacement is inserted throughout rather than over anything; the tool says so when it happens. And a pattern that applies a quantifier to an already-quantified group, like (a+)+, can take exponentially long on a long line. That gets flagged before it runs, because once a regular expression starts there is no way to interrupt it.

Frequently Asked Questions

How do I use regular expressions here?

Choose "Regular expression" and type a pattern in the Find field — \d{4} for any four digits, for example. The search always runs globally, and turning off Match case adds the case-insensitive flag. In the Replace field you can reference capture groups with $1, $2 and so on, a named group with $<name>, and the whole match with $&. Three flag toggles appear in regex mode: line anchors for ^ and $, letting . match a newline, and Unicode mode for classes like \p{L}.

Why did my replacement mangle a dollar sign or a price?

That was a real bug in the previous version of this tool and it is fixed. In plain-text mode the replacement is now inserted exactly as typed, so US$50, $$ and $& all survive. In regex mode a dollar sign keeps its special meaning on purpose, because that is how you reference capture groups — if you need a literal dollar in a regex replacement, type $$ for one dollar sign, or switch to plain text.

Why does my pattern with ^ only change the first line?

It should not any more. Line anchors are on by default in regex mode, which means ^ matches at the start of every line and $ at the end of every line rather than only at the ends of the whole text. If you specifically want the old behaviour — anchoring to the whole block — untick "^ and $ match each line". A pattern that needs to span lines also wants "Let . match a newline", since a dot stops at a line break otherwise.

Can I run several replacements at once?

Yes. Press Add rule for as many find-and-replace pairs as you need, up to 25. They run from top to bottom, each over the output of the one before it, and each shows its own replacement count. Reorder them with the arrows, switch individual ones off without deleting them, and watch out for a later rule matching text an earlier one produced — the per-rule counts are what makes that visible. The Ready-made replacements panel fills in common ones for you.

Does it replace every occurrence or just the first?

Every occurrence by default, with the total shown next to the rules. If you would rather go carefully, Replace next applies a single occurrence of the first active rule and writes it back into the text, so you can step through a document and undo any step. Where to replace also lets you restrict the whole operation to lines that contain, or do not contain, a given piece of text — useful when only some rows of a list should be touched.

Is my text kept private, and is it saved anywhere?

The replacement runs locally using JavaScript's own string and RegExp engine, and nothing is uploaded. By default the tool does keep your text and your rules in this browser's local storage so a refresh does not lose them — that is the checkbox under the text box, and unticking it or pressing Clear removes the saved copy at once. Nothing over 200,000 characters is stored at all, and if you are working on a machine other people use, turn it off before you paste anything sensitive.

Related Tools

Advertisement
Buy Me a Coffee