Utility · Apr 15, 2026 · Updated Oct 14, 2026 · 5 min read

Mastering Find and Replace (With Regex Power)

How plain-text, whole-word and regex find-and-replace actually behave, tested on our own tool: whole-word matching missed "café" and every Cyrillic word, and a "$$" in a plain-text replacement turned into one dollar sign, until we fixed both. Plus replacement patterns, pipelines and why a regex can change meaning between languages.

Three Modes, Three Different Searches

What We Found When We Tested Our Own Tool

We ran the Find and Replace tool's own matching code on eight cases with known answers. Half failed, so we fixed the tool and ran them again:

CaseBefore the fixAfter
Whole word: catcorrectcorrect
Whole word: accentedcafé bars café.correct
Whole word: Cyrillicкот котик котcorrect
Plain text: $$ in replacementUS$9correct
Plain text: $& in replacementxxcorrect
Regex: swap namescorrectcorrect
Regex: reformat datecorrectcorrect
Pipeline: collapse then trimcorrectcorrect

Two separate bugs were behind the failures. Whole-word mode wrapped the search in \b, and in JavaScript \b only knows ASCII letters, so an accented "é" counted as a word boundary: "café" matched inside "cafés" and never on its own, and Cyrillic words never matched at all. Whole-word mode now checks for letters and digits in any script with Unicode property escapes (\p{L}, \p{N}) in lookbehind and lookahead, which MDN's compatibility data lists in Chrome 62, Firefox 78 and Safari 16.4. Second, plain-text replacements went through JavaScript's replacement patterns, so $$ collapsed to one dollar sign and $& inserted the match; plain-text mode now inserts the replacement literally.

The same pattern can behave differently elsewhere. Python's \b is Unicode-aware for text, so re.sub(r'\bcafé\b', 'bar', 'café cafés café.') gives the right answer that JavaScript's \b does not. Davis and colleagues (2019, found through alphaXiv) surveyed 158 developers, most of whom reuse regexes across languages, and tested 537,806 regexes from 193,524 projects in eight languages: 15% behaved differently in another language and 10% performed differently. Test a pasted regex in the engine you will run it in.

Replacement Patterns in Regex Mode

In the replacementInserts
$1, $2the text matched by capture group 1, 2...
$<name>a named group, (?<year>\d{4})
$&the whole match
$$a literal dollar sign

Swapping "Smith, John" to "John Smith" with (\w+), (\w+) and $2 $1, and turning 2026-04-15 into 04/15/2026 with (\d{4})-(\d{2})-(\d{2}) and $2/$3/$1, both passed. A replacement string cannot change case; there is no lowercase or uppercase operator in JavaScript replacements, so normalizing capitalization needs a separate step outside the tool.

Multi-Rule Pipelines

Rules run top to bottom, each on the previous rule's output. Collapsing whitespace with \s+ to one space and then trimming with ^\s+|\s+$ turned " a b " into "a b" in our test. One limit to know: the tool does not set the multiline flag, so ^ and $ match the start and end of the whole text, not of each line. To act on every line, match the line break itself, for example \n\s+ to strip leading spaces after each newline.

Real-World Workflows

Try the tool

Plain text or regex, multi-rule sequential replacement.

Open Find and Replace →

Frequently Asked Questions

Why is my regex not matching?
The usual causes: an unescaped special character (. * ? + ( ) [ ] mean something in regex), case sensitivity, or anchors. In this tool ^ and $ match the start and end of the whole text, not each line, because the multiline flag is not set. A regex copied from Python or PHP can also behave differently in JavaScript.
What's the difference between whole-word and plain text?
Plain text matches anywhere, including inside longer words. Whole-word matches only where the text is not part of a longer word, counting letters and digits in any script, so "cat" skips "category" and "café" skips "cafés".
Can I use capture groups with plain text?
No, capture groups only work in regex mode. If you need to reference parts of the matched text, switch to regex and wrap those parts in parentheses.
How do multi-rule pipelines work?
Rules run top-to-bottom. Rule 1's output becomes Rule 2's input. Each subsequent rule sees the transformed text, not the original. This lets you chain transformations.
Is this safe for sensitive data?
Yes. All processing happens in your browser. Nothing is sent to any server. You can use it to sanitize logs, scrub personally identifiable information, or process confidential text.
⚡ Try the free Regex to Plain English →

Published Apr 15, 2026 · Updated Oct 14, 2026 by Derek Giordano

📚 References & Further Reading
Browse all utility tools →
⚡Find and Replace Text→
ColorHow to Find the Name of Any Color→ContentHow to Find and Copy Emojis by Name or Category→CSSHow to Find the Closest Tailwind CSS Color→DeveloperHow to Test Regular Expressions Online→DeveloperRegular Expressions Explained→UtilityAction Verbs for Your Resume: 150+ Power Words by Industry (2026)→