浏览代码

dictionary: Rewrite how the regex to match terms gets constructed

Will Storey 8 年之前
父节点
当前提交
107e34a1c9
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      dictionary.tcl

+ 4 - 3
dictionary.tcl

@@ -277,11 +277,12 @@ proc ::dictionary::is_addressing_bot {text botnick} {
 # hitest
 proc ::dictionary::string_contains_term {s term} {
   set term_lc [string tolower $term]
-
   set term_quoted [::dictionary::quotemeta $term_lc]
 
-  # \m matches at the beginning of a word, \M at the end.
-  return [regexp -nocase -- \\m$term_quoted\\M $s]
+  set re {\m}
+  append re $term_quoted
+  append re {\M}
+  return [regexp -nocase -- $re $s]
 }
 
 # Escape/quote metacharacters so that the string becomes suitable for placing in