From eee76a5b5d2f24383bf4b78b0861f1c26aa9cee4 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 30 Oct 2011 22:40:57 +0100 Subject: [PATCH] dont match substrings at beginging of value --- pandora/event/models.py | 4 +--- pandora/place/models.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pandora/event/models.py b/pandora/event/models.py index f7d1baaa..1141b96c 100644 --- a/pandora/event/models.py +++ b/pandora/event/models.py @@ -76,9 +76,7 @@ class Event(models.Model): value = a.value.lower() for name in [self.name] + list(self.alternativeNames): name = name.lower() - if name in value and (value.startswith(name) or \ - value.endswith(name) or \ - re.compile('\s%s[\.,;:!?\-\/\s]'%name).findall(value)): + if name in value and re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%name): matches.append(a.id) break if not matches: diff --git a/pandora/place/models.py b/pandora/place/models.py index 03d31335..59c074f3 100644 --- a/pandora/place/models.py +++ b/pandora/place/models.py @@ -86,9 +86,7 @@ class Place(models.Model): value = a.value.lower() for name in [self.name] + list(self.alternativeNames): name = name.lower() - if name in value and (value.startswith(name) or \ - value.endswith(name) or \ - re.compile('\s%s[\.,;:!?\-\/\s]'%name).findall(value)): + if name in value and re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%name): matches.append(a.id) break if not matches: