]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
factoids plugin: fix regexp for words such as jsn-
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 27 Mar 2008 20:13:37 +0000 (21:13 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 27 Mar 2008 20:13:37 +0000 (21:13 +0100)
data/rbot/plugins/factoids.rb

index aeb6557fc8d534d221f1fb2b90c2933c75bed0b0..3192aa00e450d211de79f7aa9a0cad1ca944a5ac 100644 (file)
@@ -331,7 +331,9 @@ class FactoidsPlugin < Plugin
     # When looking for words we separate them with
     # arbitrary whitespace, not whatever they came with
     pre = words.map { |w| Regexp.escape(w)}.join("\\s+")
-    return Regexp.new("\\b#{pre}\\b", true)
+    pre << '\b' if pre.match(/\b$/)
+    pre = '\b' + pre if pre.match(/^\b/)
+    return Regexp.new(pre, true)
   end
 
   def facts(m, params)