Skip to content
gohacks.dev
Tooling

Find and Replace

Find and replace in text with plain search or regular expressions, capture groups in the replacement, whole-word and case options, and a count of replacements.

Free · No sign-up · Your inputs stay in your browser

Input

Find and replace text, with regex

Output

Result

3 replacements

JavaScript regex syntax, with ^ and $ matching at each line. The same replacement in a terminal is sed -E 's/pattern/replacement/g' file (with \1 instead of $1), or in a whole project, rg -l 'pattern' | xargs sed -i ... after checking the matches.

Runs in this browser. Nothing you paste is sent to a server.

Regex replacements

Capture groups turn find and replace into a transformation: (\w+)@(\w+)\.com with $2: $1 reorders parts of every match. The String.replace reference documents the replacement patterns.

Across files

For a whole project, rg -l 'pattern' lists the files that match and sed -i -E 's/pattern/replacement/g' edits them (with \1 instead of $1); review the matches before running the sed. Editors' project-wide replace with a preview is safer still.

Share

Frequently asked questions

How do I replace with a newline?
In regex mode, write a real newline in the replacement box, or use the line tools to split text first.
Why did my replacement change too much?
The pattern matched more than intended, often because . and * are special in regex. Switch to plain mode, or escape them with a backslash.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools