From: Giuseppe Bilotta Date: Thu, 27 Mar 2008 20:13:37 +0000 (+0100) Subject: factoids plugin: fix regexp for words such as jsn- X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=63eaa1da3ba602e55458ad2228b8ecc9db045b04;hp=95968ce9b07a35cf0c196491c4e050150e556bea;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git factoids plugin: fix regexp for words such as jsn- --- diff --git a/data/rbot/plugins/factoids.rb b/data/rbot/plugins/factoids.rb index aeb6557f..3192aa00 100644 --- a/data/rbot/plugins/factoids.rb +++ b/data/rbot/plugins/factoids.rb @@ -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)