From d211ad5c9efe0eca9533081dba76fe08d6856b7c Mon Sep 17 00:00:00 2001 From: Ross Poulton Date: Thu, 6 Aug 2009 09:00:53 +0000 Subject: [PATCH] Issue #91: Improve the regex used for matching ticket numbers to links, thanks to Sumeet A. --- templatetags/ticket_to_link.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templatetags/ticket_to_link.py b/templatetags/ticket_to_link.py index cf5dfa57..c5f84eea 100644 --- a/templatetags/ticket_to_link.py +++ b/templatetags/ticket_to_link.py @@ -37,7 +37,7 @@ def num_to_link(text): return text matches = [] - for match in re.finditer(" #(\d+)", text): + for match in re.finditer(r"(?:[^&]|\b|^)#(\d+)\b", text): matches.append(match) for match in ReverseProxy(matches): @@ -52,7 +52,7 @@ def num_to_link(text): if ticket: style = ticket.get_status_display() - text = "%s#%s%s" % (text[:match.start()], url, style, match.groups()[0], text[match.end():]) + text = "%s #%s%s" % (text[:match.start()], url, style, match.groups()[0], text[match.end():]) return mark_safe(text) register = template.Library()