Bläddra i källkod

dictionary: Rewrite how the regex to match terms gets constructed

Will Storey 8 år sedan
förälder
incheckning
107e34a1c9
1 ändrade filer med 4 tillägg och 3 borttagningar
  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