# Правила сопоставления чисел в отслеживаемых словах

**URL:** https://meta.discourse.org/t/rules-for-number-matching-in-watched-words/396110
**Category:** Bug
**Tags:** watched-words
**Created:** [14.Февраль.2026 15:47:09 UTC](https://meta.discourse.org/t/rules-for-number-matching-in-watched-words/396110 "2026-02-14T15:47:09Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [21.Февраль.2026 10:54:55 UTC](https://meta.discourse.org/t/rules-for-number-matching-in-watched-words/396110/5 "2026-02-21T10:54:55Z")

</div>

На этот раз это должно решить проблему раз и навсегда. У нас была некоторая несогласованность между версиями регулярных выражений на Ruby и JS, но теперь это больше не требуется.

> <https://github.com/discourse/discourse/pull/37965>
>
> The CJK fix (d7a53ada16) introduced separate boundary patterns for Ruby and JS e…ngines in \`match\_word\_regexp\`. The Ruby engine used \`\[:word:\]\` (which includes digits), while the JS engine used \`\\P{L}\` (non-Letter). Since digits are not letters, the JS pattern treated them as valid word boundaries — causing "123Test" to match as "3Test" and standalone number watched words like "123" to match inside "abc123".
> 
> Replace both engine-specific patterns with a single unified pattern using Unicode property classes (\`\\p{L}\`, \`\\p{M}\`, \`\\p{N}\`, \`\\p{Pc}\`) that work identically in Ruby and JavaScript. This treats letters, marks, numbers, and connector punctuation as word characters in boundary checks, which fixes the number-matching bug for JS consumers while preserving the existing correct behavior on the Ruby side.
> 
> Since \`match\_word\_regexp\` no longer branches on engine, remove the now-dead \`engine:\` parameter from all 5 method signatures that threaded it through (\`match\_word\_regexp\`, \`word\_to\_regexp\`, \`regexps\_for\_action\`, \`compiled\_regexps\_for\_action\`, \`serialized\_regexps\_for\_action\`) and all call sites passing \`engine: :js\` (serializers, pretty\_text).
> 
> https://meta.discourse.org/t/396110
> https://meta.discourse.org/t/396109
> 
> Follow-up to d7a53ada16 (#37844)

---

_[View the full topic](https://meta.discourse.org/t/rules-for-number-matching-in-watched-words/396110)._
