Find and replace text

Substitute literal text or an ECMAScript regular-expression pattern once or globally, with explicit case and word-boundary controls.

freeworks offlinenothing uploaded
ToolFind & Replace
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Literal mode escapes regex metacharacters before optional \b wrapping; regex mode compiles the entered source directly. Flags g and i control global matching and case folding, then String.prototype.replace interprets ECMAScript replacement tokens such as $&, $1, and $$.

  • Literal, case-sensitive, replace-all behavior is selected first because it gives ordinary text search predictable semantics.
  • Invalid raw patterns fail during RegExp construction before any source text is changed.

Worked example

Simple text replacement
Replace all occurrences of a word in text
Input
											Input: The quick brown fox jumps over the lazy fox.
Find: fox
Replace: cat
										
Output
												The quick brown cat jumps over the lazy cat.
											

When to use this

Documentation edits rename terms, log cleanup removes timestamp patterns, and delimited-data repairs replace exact separators.

Edge cases

  • An unclosed parenthesis in regex mode raises a pattern error instead of performing a partial substitution.
  • Whole-word mode uses JavaScript \b, so accented and non-Latin letters do not participate as full Unicode word characters.
  • Replacement $& inserts the complete match, $1 inserts a captured group, and $$ inserts one literal dollar sign.

References