Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/desktop/src/utils/text-replacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ export function applyTextReplacements(
const regex = new RegExp(escapedWord, "giu");
result = result.replace(regex, replacement);
} else {
// Alphabetic languages: Use Unicode-aware word boundary matching
// Negative lookbehind/lookahead ensures word is not part of a larger word
// Alphabetic languages: Use word boundary matching
// Only check Latin script boundaries to prevent "apple" matching in "pineapple"
// but allow matching adjacent to CJK characters (e.g., "Xavixの設定")
const regex = new RegExp(
`(?<![\\p{L}\\p{N}])${escapedWord}(?![\\p{L}\\p{N}])`,
`(?<![\\p{Script=Latin}\\p{N}])${escapedWord}(?![\\p{Script=Latin}\\p{N}])`,
"giu",
);
result = result.replace(regex, replacement);
Expand Down