How to find and replace text online
- Paste your text into Text.
- Type what to look for in Find and the new wording in Replace with. The Result updates as you type, and the line under it counts the replacements.
- Tick Match case if capitals matter, and Whole words only to skip matches inside longer words.
- Tick Regular expression to search by pattern. Then
^and$match at the start and end of each line, and$1,$2in the replacement insert capture groups. - Press Copy result, or Use result as text to run a second replacement on the result.
How matching works
In plain mode the tool looks for exactly what you typed, spaces included, and inserts your replacement as typed, so characters such as $ and \ need no escaping. Whole-word matching checks that a match does not touch a letter, number or underscore on either side. It uses Unicode letter classes, so café and C++ count as whole words, which the plain ASCII word boundary (\b) gets wrong.
Regular expression mode uses your browser's JavaScript engine, described in the MDN regular expressions guide. The replacement follows the String.replace rules: $1 is the first group, $& the whole match and $$ a literal dollar sign. In regex mode you can also type \n for a line break and \t for a tab in the Replace box.
Worked example with the default text
The sample text is The quick brown fox jumps over the lazy dog. The dog was sleepy. With Find set to dog, Replace with set to cat and Match case ticked, the result is The quick brown fox jumps over the lazy cat. The cat was sleepy. and the tool reports 2 replacements made.
Common jobs and the patterns for them
- Swap first and last names: tick Regular expression, Find
(\w+) (\w+), Replace with$2, $1. Jane Doe becomes Doe, Jane. - Reformat dates: Find
(\d{4})-(\d{2})-(\d{2}), Replace with$2/$3/$1. 2026-10-06 becomes 10/06/2026. - Strip HTML tags: Find
<[^>]+>and leave Replace with empty.
Limits and edge cases
A regex that backtracks without end, such as (a+)+$ on a long run of letters, is stopped after four seconds with a message, so the page stays responsive. There is no undo, so keep your original text. Build a tricky pattern first in the Regex Tester. For stray spaces and blank lines, the Whitespace Cleaner is quicker, and the Duplicate Line Remover drops repeated lines.
Frequently asked questions
How do I replace text with a new line?
Click into Replace with and press Enter, or press its Line break button, then type the rest. In regular expression mode you can also type \n. To go the other way, put a line break in Find and a comma in Replace with.
How do I use capture groups like $1?
Tick Regular expression and wrap part of your pattern in brackets. In Replace with, $1 inserts the first bracketed part, $2 the second and $& the whole match. For example, Find (\w+) (\w+) and Replace with $2, $1 turns Jane Doe into Doe, Jane.
How do I replace only whole words?
Tick Whole words only. A match must not touch a letter, number or underscore on either side, so cat is replaced but category and concat are left alone.
How do I add text to the start of every line?
Tick Regular expression, type ^ in Find and the text to add in Replace with. The ^ matches the start of each line, so every line gets the prefix. Use $ instead of ^ to add text to the end of every line.
Is find and replace case sensitive?
It is by default, because Match case starts ticked, so dog does not match Dog. Untick Match case to replace every capitalization. The replacement is inserted exactly as typed, so a capital letter at the start of a sentence is not kept.
Sources: MDN, String.prototype.replace; MDN, Regular expressions; MDN, Lookbehind assertion.