Find and Replace Text
Run a find and replace over a whole block of text at once. Match a literal string or a regular expression, keep capture groups so parts of each match can be reused in the replacement, and restrict matching to whole words or an exact case. The number of replacements is reported, so you can tell whether the pattern did what you expected.
Text Tools
Private by default
This tool runs entirely in your browser. Your data is never uploaded to a server.
How it works
How the search is run
new RegExp(pattern, "g") — plus "i" when case is ignored
Both modes compile to the same regular expression: with the regex box unticked, the search text is escaped first so every character matches itself. Whole-word mode wraps the pattern in word boundaries, and the replacement runs across the whole text in one pass.
- In literal mode a $ in the replacement is escaped too, so $1 is inserted as the characters $1 rather than a capture group.
- A word boundary sits between a word character and a non-word one, so it will not isolate a term containing a hyphen or a full stop.
- Patterns that can match an empty string are handled without looping forever, but they rarely do what you meant.
- Matching is on the text as given: nothing is normalised, so a curly apostrophe and a straight one stay different characters.
For reference
Patterns worth knowing
| Pattern | Matches |
|---|---|
| \d+ | One or more digits |
| \w+ | A word: letters, digits, underscore |
| \s+ | Any run of whitespace |
| ^\s+|\s+$ | Leading or trailing whitespace on a line |
| (\w+)@(\w+) | Two parts either side of an @, captured |
| \n{2,} | Two or more consecutive line breaks |
Anchors ^ and $ match the start and end of the whole text here, not of each line — add \n to the pattern to work line by line.
How to use
4 clear steps.
Paste the text you want to change.
Enter what to find — a literal string, or a pattern with the regex box ticked.
Enter the replacement, using $1 and $2 for capture groups.
Check the match count, then copy the result.
Good to know
Frequently asked questions
- How do I reuse part of what I matched?
- Put brackets around the part you want to keep and reference it as $1 in the replacement. Matching `user=(\w+)` and replacing with `user=[$1]` wraps each username in brackets while leaving it intact.
- What if my search text contains regex characters?
- Untick the regex box. The search text is then escaped before use, so a full stop matches a full stop and brackets match brackets rather than being read as syntax.
- Can I replace only the first occurrence?
- Not here — every replacement is global, which is what a bulk edit is for. To target one occurrence, make the pattern specific enough that it only matches once, for instance by including surrounding text.
- Why does my pattern match nothing?
- The most common causes are case sensitivity, which is on by default, and characters that look alike — a non-breaking space, a curly apostrophe, or a different dash. Try a shorter pattern and build it up.