How the search and replace behaves
Everything you type is turned into a JavaScript regular expression with the global flag, so every match in the text is replaced in a single pass. The "Case sensitive" box is off by default, which adds the i flag: searching for cat matches Cat and CAT too. The replacement is inserted as typed, so it does not copy the capitalisation of what it replaced.
- Regex off: the find box is treated as plain text. Characters that are special in regular expressions, such as
.,*,?and(, are escaped for you, so a search fora.bonly matches those three characters. - Regex on: the box is used as a pattern, with groups, classes and anchors. An invalid pattern shows an error message instead of changing your text.
- The "Matches found" counter shows how many replacements were made.
Replacement tokens
These apply only when Regex is on, where the replacement follows JavaScript's rules: $1, $2 and so on insert capture groups, $& inserts the whole match, and $$ inserts a literal dollar sign. With Regex off, the replacement is inserted exactly as typed, so replacing a word with $1 or $& gives you those characters, not a group or the match.
Tested examples
| Goal | Find (regex on) | Replace | Result |
|---|---|---|---|
| Swap name order | (\w+) (\w+) | $2 $1 | John Smith, Jane Doe becomes Smith John, Doe Jane (2 matches) |
| Reformat a date | (\d{4})-(\d{2})-(\d{2}) | $3/$2/$1 | 2024-03-15 becomes 15/03/2024 |
| Lines to a list | \n | , | a, b, c on separate lines becomes a, b, c |
| Squeeze spaces | {2,} | one space | x y z becomes x y z |
Limits and gotchas
- There is no multiline flag, so
^and$match only the very start and end of the whole text and not of each line. To add something to every line, use Add Prefix and Suffix to Lines instead. - The dot does not match line breaks, and there is no option to change that.
- The tool replaces all matches at once. There is no way to step through them one at a time or to preview highlights, so check the counter before copying.
- Greedy patterns such as
.*can match far more than intended. Try a pattern in the regex tester first, and see the regex cheat sheet for the syntax.