Skip to content

Find and replace text

Paste your text, type what to find and what to put in its place. Matches light up while you type.

Ready rules:
0 characters, 0 lines
Line breaks

Lines broken in the middle of sentences, like text from a PDF? The text cleaner joins them and keeps the paragraphs.

Rules file

Download your rules as a small file. Open it here later or on another computer.

Advertisement
A magnifying glass over a line of text, with one word being swapped for another

Last checked by the TextEditor.com team

Match case, whole words and regex

A plain search finds the letters wherever they are, also inside longer words. Whole words skips a match when a letter or digit touches it on either side. Match case treats "Cat" and "cat" as different words.

What a search for your word finds

The cat sat on the Cat Mat. A category of cats is a catalog.

OptionsMatches
None5: cat, Cat, cat, cat, cat
Match case4: cat, cat, cat, cat
Whole words2: cat, Cat
Match case and whole words1: cat

Regex patterns worth knowing

A regular expression, or regex, is a search pattern. A few signs stand for whole groups of characters, so one pattern can find every number or every email address. Press "Try it" to load a pattern into the tool above.

PatternFindsLoad
\d+Any number, like 7 or 2026
\s+$Spaces at the end of each line
^\s*$\nEmpty lines
colou?r"color" and "colour"; the ? makes the u optional
cat|dog"cat" or "dog"
\b[A-Z]{2,}\bWords in capitals, like NATO; turn on Match case
[\w.+-]+@[\w-]+\.[\w.]+Most email addresses
https?://\S+Web links

To find a sign that has a meaning in regex, put a backslash in front of it: \. finds a period and \( finds a bracket. With Regex off, every sign is found as you type it.

To build and check a pattern first, with every match, its groups and a plain words explanation, use the regex tester.

Swap and reuse parts with $1 and $2

Brackets in a pattern make a group. In the Replace box, $1 puts back what the first group found, $2 the second, and so on. $0 puts back the whole match.

Last name, first name to first name last name

Find (\w+), (\w+) and replace with $2 $1

Result
Ada Lovelace
Grace Hopper
Alan Turing

Named groups work too: (?<year>\d{4}) in the pattern and $<year> in the replacement.

Several rules in a row: order matters

Press "Add a rule" to run more than one search at once. Rules run from top to bottom, and each rule works on the text the rule above left behind. Turn a rule off with the box on its left.

That is why swapping two words needs a third step. Change "cats" to "dogs" first, and the next rule turns every "dogs" back into "cats", the old ones and the new ones. A placeholder that is not in the text fixes it.

Swap "cats" and "dogs" in "cats chase dogs"
Rules in orderResult
cats → dogs, then dogs → catscats chase cats
cats → @@, then dogs → cats, then @@ → dogsdogs chase cats

Rules you use often can go in a file. Open Rules file and press "Download rules". Next time, press "Open rules file" and pick that file, on this computer or another.

Advertisement

Removing line breaks without losing paragraphs

A paragraph ends with an empty line, which is two line breaks in a row. With "Keep paragraphs" on, Remove line breaks joins the lines inside each paragraph and leaves the empty lines alone. With it off, the whole text becomes one long line. For text from a PDF, with split words and lists, use remove line breaks. It shows each change before you copy.

Before and after
Roses are red,
violets are blue.

Sugar is sweet,
and so are you.

In place of each break you can put a space, nothing, a comma or your own text. A comma turns a list with one item per line into one line for a spreadsheet or a tag field. "Add line breaks" does the opposite: it breaks long lines at the last space before the length you pick, so a text fits an old email or a terminal. To put the lines of a list in order or drop the repeats, use sort lines.

Line breaks in Word, Excel and code editors

Each program writes a line break in its own way in the Find box. Checked November 2026.

ProgramLine break in FindNotes
Microsoft Word^p, ^l^p is a paragraph mark, ^l a manual line break. Pick them under More, then Special, as Microsoft shows in its Word help page.
ExcelCtrl+JPress Ctrl+J in the Find what box. The box looks empty, but it holds the line break.
Visual Studio Code\nTurn on Use Regular Expression (.*). Ctrl+Enter adds a new line in the box.
This page\nWorks with Regex on or off, as long as "\n is a line break" is on.

Why a pattern can freeze a page

Some patterns take a very long time on some texts. (a+)+$ on a long row of the letter a followed by a b has to try millions of ways to split the row before it gives up. This problem is called ReDoS.

This tool first tests each pattern in a separate background task. If the test takes more than a second, the task is stopped and the tool shows "Pattern too slow", so the page keeps working. Patterns without nested repeats like (a+)+ are almost never slow.

Other ways to fix text

Frequently asked questions

How do I replace a word with a line break?

Type the word in Find and \n in Replace with, then press Replace all. The box "\n is a line break" must be on, which it is by default.

How do I remove all line breaks but keep paragraphs?

Press Remove line breaks under Line breaks, with "Keep paragraphs" on. Lines inside a paragraph are joined with a space, and the empty lines between paragraphs stay. The remove line breaks page does the same and also keeps lists.

What does $1 mean in the Replace box?

With Regex on, $1 is the text that the first group in brackets found. $2 is the second group and $0 the whole match. "Smith, John" with (\w+), (\w+) and $2 $1 becomes "John Smith".

Why does my pattern show an error?

Some signs have a meaning in regex, like ( [ * + and ?. A bracket without its partner or a star with nothing before it is an error. The message says what is wrong. Put a backslash in front of the sign, or turn off Regex to search for it as typed.

Can I undo a replace?

Yes. Press Undo, or Ctrl+Z right after the change. The tool keeps the last 20 versions of the text.

Does it work with emoji and other languages?

Yes. Searches work on whole characters, so an emoji with a skin tone is found as one. Whole words and Match case work for every alphabet, like Greek, Cyrillic and Arabic.

Is my text uploaded?

No. Everything runs in your browser. Your text and rules are saved only in this browser.

  • Text editorWrite and edit plain text in your browser.
  • Text comparePaste two texts and see every changed line and word highlighted side by side.
  • Word counterCount words, sentences and paragraphs as you type.
  • NotepadKeep several notes in one place.
  • Code editorWrite or paste HTML, CSS, JavaScript, JSON, Python, SQL and more with colors, line numbers and a format button.
  • Invisible characterCopy an invisible character or blank space for empty names and messages.

↑ ↓ to choose, Enter to open, Esc to close