Find & Replace

Search any block of text and rewrite it — in plain text or as a regular expression. The match counter and inline highlights update as you type. With preserve case turned on, the replacement adapts to each match’s case shape, so renaming foo to bar turns MyFooWidget into MyBarWidget, fooWidget into barWidget, and FOO into BAR. Nothing leaves your browser.

Find & replace
Result

Backreferences in the replacement

When the find field is a regex, the replacement supports the same backreferences as JavaScript’s String.prototype.replace:

  • $& — the entire match
  • $1, $2, ... — the 1st, 2nd, ... capture group
  • $\` — the text before the match
  • $' — the text after the match
  • $$ — a literal $

Preserve case

The tool detects the case shape of each match and rewrites the replacement to match. The five shapes it understands:

  • UPPERCASEFOOBAR
  • lowercasefoobar
  • Title CaseFooBar
  • PascalCaseFooBarBarBaz (when the replacement is bar baz)
  • camelCasefooBarbarBaz

Tip for renaming identifiers: turn on regex and use a pattern like \bfoo\w+ to match the full identifier (foo, fooBar, FOO_BAR).