Find & Replace
Understand Find & Replace
Finds and replaces text across a whole document, either as literal text or with a regular expression.
How it works
In literal mode every regex metacharacter in your search term is escaped first, so a search for `a.b` matches exactly `a.b` and not "a, any character, b". In regex mode your pattern is compiled as written, with the global flag on unless you turn it off and the ignore-case flag on unless you ask for case sensitivity. Only regex mode gives the dollar sign a meaning in the replacement: `$1` inserts the first capture group, and a dollar sign followed by an ampersand inserts the whole match. So a pattern of `(\w+)@(\w+\.\w+)` with a replacement of `$2/$1` turns `user@example.com` into `example.com/user`.
When to use it
- Renaming a symbol or a URL across a pasted file without opening an editor
- Reshaping a column of data — stripping a prefix, swapping two fields, normalizing separators — with one capture-group pattern
- Stripping noise out of a log paste, such as timestamps or ANSI escape sequences
- Converting a delimiter, for example turning tabs into commas before importing a file
Watch out for
- Matching is case-insensitive unless you turn case sensitivity on, which is the opposite of most editors. A replace of "id" will also hit "ID" and "Id" until you change it.
- In regex mode without the global option only the first match is replaced. In literal mode `$1` and `amp;` are inserted as plain text rather than interpreted, so the two modes treat the same replacement string differently.
- A pattern with nested quantifiers such as `(a+)+b` can backtrack catastrophically and freeze the tab on a long input. Anchor your patterns and avoid nesting a quantifier inside another.
- Replacing in the middle of structured text breaks it quietly. A literal replace inside JSON, CSV, or HTML has no idea it is inside a quoted string or an attribute — validate the output afterwards.
Frequently Asked Questions
How do I do a case-insensitive find and replace?
Enable "Case insensitive" mode (or add the "i" flag in regex mode). The search matches uppercase, lowercase, and mixed-case occurrences. The replacement preserves the exact case of the matched text, not the search term.
How do I use regex backreferences in replacement?
Capture groups from the find pattern are referenced in the replacement as $1, $2, and so on. For example, find (\w+)@(\w+\.\w+) and replace with $2/$1 turns user@domain.com into domain.com/user. Named groups use
lt;name>, a dollar sign followed by an ampersand inserts the whole match, and $ inserts a literal dollar sign.Can I replace across multiple lines?
Enable regex mode and add the "s" (dotAll) or "m" (multiline) flags. The "m" flag makes ^ and $ match line boundaries; "s" makes dot (.) match newline characters for cross-line patterns.
How to Use Find & Replace
- Paste or type your input in the input area above.
- The tool processes your input automatically or click Run.
- Copy or download the result using the action buttons.
- Use Ctrl+Enter to run quickly from the keyboard.