# Watched word regular expression crash (2025)

**URL:** <https://meta.discourse.org/t/watched-word-regular-expression-crash-2025/382417>\
**Category:** Bug\
**Tags:** regex, watched-words\
**Created:** [September 12, 2025, 9:11am UTC](https://meta.discourse.org/t/watched-word-regular-expression-crash-2025/382417 "2025-09-12T09:11:45Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [September 15, 2025, 8:17am UTC](https://meta.discourse.org/t/watched-word-regular-expression-crash-2025/382417/6 "2025-09-15T08:17:27Z")

</div>

> [@sam](#):
>
> Valildating regex in on save

That won’t prevent people entering “normal” wildcard expressions, and _then_ turning on `watched words regular expressions enabled`, which is what happened here.

I think it just needs an exception handler [around](https://github.com/discourse/discourse/blob/main/app/services/word_watcher.rb#L239) the regexp call

```rb
  def word_matches?(word, case_sensitive: false)
    options = case_sensitive ? nil : Regexp::IGNORECASE
    Regexp.new(WordWatcher.word_to_regexp(word), options).match?(@raw)
  end

```

---

_[View the full topic](https://meta.discourse.org/t/watched-word-regular-expression-crash-2025/382417)._
