Find and replace

Find text and replace every match, with optional regular expressions.

Runs in your browser. Nothing you type is sent anywhere.

How to find and replace text

  1. Paste your text and type what you want to find.
  2. Type the replacement text, or turn on regular expressions for pattern matching.
  3. Check the match count, then copy or download the result.

Common regular expressions

PatternMatches
\d+One or more digits, like 42 or 2024
\s+One or more spaces, tabs or line breaks
^The start of the text, or of each line with the m flag
$The end of the text, or of each line with the m flag
[A-Za-z]+One or more letters in a row

Every match gets replaced, always

This tool always replaces every match in the text, not just the first one. The g flag is added to your pattern automatically even if you leave the flags field blank or forget to type it yourself, so there's no way to accidentally replace only one occurrence using the regular expression option here.

Find and replace FAQ

What is a regular expression and when do I need one?

A regular expression is a pattern that matches text by rule instead of an exact phrase, such as any digit or any word ending in "ing". Use it when a plain find cannot describe what you want to match.

What do the flags do?

The g flag replaces every match instead of just the first, and this tool always adds it automatically even if you leave the field blank. The i flag makes the match case insensitive. The m flag makes ^ and $ match the start and end of each line instead of the whole text.

Can I remove text instead of replacing it?

Yes, leave the replace field empty and every match is deleted.

Why does my replacement say the pattern is not valid?

That message appears when the regular expression has a syntax error, such as an unmatched bracket or parenthesis. Check the pattern and try again.

Should I use remove line breaks or extra spaces instead of a regular expression?

For those specific jobs, yes. The remove line breaks and remove extra spaces tools handle them with dedicated options and no pattern to write, which is faster than building a regular expression here.

Does find and replace work across multiple lines at once?

Yes, it searches the whole pasted text as one block by default, so a plain find matches across line breaks too, not only within a single line.

Related tools