A whole-word option can miss café on its own yet replace the same letters at the start of caféine. The result depends on the matching rule behind the checkbox. A visible word and a JavaScript regular-expression word boundary are different things.
Use a small sample before making a bulk edit. The example below deliberately keeps a longer label and a hyphenated term unchanged, then supplies a narrow rule for the surrounding punctuation.
Reproduce the unexpected replacement
Open Find and Replace Text and paste this into Your text:
Visit the café. Keep the label caféine. Compare café-bar.
Set Find to café and Replace with to bistro. Enable Match case, Whole word only and Replace all. Leave Use regular expression off, then select Replace.
The current tool reports one replacement and returns:
Visit the café. Keep the label bistroine. Compare café-bar.
The intended standalone term stayed unchanged, while the longer label changed. Simply turning off Whole word only is not the repair: this sample then receives three replacements, including the unwanted changes inside caféine and café-bar.
Check what the boundary actually means
The tool currently surrounds a whole-word search with JavaScript \b assertions. Its matching mode treats the usual ASCII letters, digits and underscore as word characters. In this example, é is outside that group.
MDN’s word-boundary reference explains that a boundary separates a word character from a non-word character, or the reverse. After the é in café., both that letter and the period are non-word characters under this rule, so the required final boundary is absent. In caféine, the following i is a word character, so a boundary exists in the middle of the visible label.
The sample uses a single U+00E9 character for é. This is a boundary diagnosis, not a Unicode-normalization procedure or a language-aware definition of every word.
Use a declared delimiter rule for this sample
For this particular edit, accept the term at the start or end of the text, or next to spaces, tabs, line breaks and these characters: .,;:!?(). Keep a hyphenated term and a longer label unchanged. These are explicit editorial choices for the sample.
- Restore the untouched original sample in Your text.
- Turn Whole word only off and Use regular expression on. Keep Match case and Replace all on.
- Enter this pattern directly in Find, without surrounding slashes or flags:
(^|[ \t\r\n.,;:!?()])café(?=$|[ \t\r\n.,;:!?()])
- Enter
$1bistroin Replace with, then select Replace.
The first parenthesized group captures the accepted character before the term, or the start of the text. The tool’s supported $1 replacement puts that captured character back. The lookahead checks the following delimiter without consuming it, as described in MDN’s lookahead reference.
Expect one replacement and this output:
Visit the bistro. Keep the label caféine. Compare café-bar.
The same tested rule changes all four occurrences in café, (café)! café café and preserves the punctuation. In a separate test, it also preserves tabs, line breaks and a blank paragraph while changing four accepted occurrences.
Test the limits before editing more text
The delimiter list does not include quotation marks, apostrophes or hyphens. A quoted "café" therefore remains unchanged with this exact pattern. So do café-bar, caféine and capitalized Café. A spelling with a separate combining accent also remains outside this exact literal search.
Do not add every punctuation character automatically. Decide which contexts should change, then test one intended match and one protected example for each added case. For broader multilingual editing, choose a process that supports the language and the desired segmentation rules, and review its output.
Keep the original, compare the replacement count with your intended changes, and inspect both altered and untouched terms before copying the result into its destination. The basic whole-word replacement guide covers ordinary ASCII examples and first-match controls; the accented example here needs its own checked boundaries.