这并不能阻止人们输入“普通”通配符表达式,然后启用 watched words regular expressions enabled,而这正是这里发生的情况。
我认为只需要在 regexp 调用 周围 添加一个异常处理程序
def word_matches?(word, case_sensitive: false)
options = case_sensitive ? nil : Regexp::IGNORECASE
Regexp.new(WordWatcher.word_to_regexp(word), options).match?(@raw)
end