diff --git a/pandora/event/models.py b/pandora/event/models.py index f7d1baaa7..1141b96cc 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 03d313357..59c074f33 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: