Features

Text replacements never match inside sentences in languages written without spaces (Japanese, Chinese, Thai, …)

29d agoCompleted

Since 1.35.0, text replacements match whole words only. In languages written without spaces between words, a word inside a sentence is never a "whole word", so replacements only work when the term is next to punctuation.

My primary language is Japanese, so here is a Japanese example. The same should apply to Chinese, Thai and other languages without spaces. Japanese attaches particles directly to nouns, with no space in between.

Replacement `ギットハブ → GitHub` (macOS, 2.19.3):

- `ギットハブ。 ("GitHub.")` -> ✅ replaced - `ギットハブの課題 ("the GitHub Issue")` -> ❌ not replaced

Explain: the second line writes like "thegithubissure": there is no boundary around "github".

**Proposal:** use Unicode word boundaries (UAX #29) for whole-word matching, e.g. `NSRegularExpression.Options.useUnicodeWordBoundaries`. In my test, this makes the second case match while still not matching inside longer words ("cat" does not match "category").

- https://www.unicode.org/reports/tr29/ - https://developer.apple.com/documentation/foundation/nsregul…

0 comments

  1. Babur Nawyan marked this as Completed19d ago
  2. Babur Nawyan marked this as In Progress22d ago