Commits

Anonymous committed 8f0ebef

[svn] re.sub doesn't take re flags, a couple places were assuming it did

Comments (0)

Files changed (1)

webhelpers/rails/text.py

     """
     if not phrase or not text:
         return text
-    return re.sub(re.compile('(%s)' % re.escape(phrase)), hilighter, text, re.I)
+    highlight_re = re.compile('(%s)' % re.escape(phrase), re.I)
+    return highlight_re.sub(hilighter, text)
 
 def excerpt(text, phrase, radius=100, excerpt_string="..."):
     """
         >>> strip_links("<a href="something">else</a>")
         "else"
     """
-    return re.sub(r'<a\b.*?>(.*?)<\/a>', r'\1', text, re.M)
+    strip_re = re.compile(r'<a\b.*?>(.*?)<\/a>', re.M)
+    return strip_re.sub(r'\1', text)
 
 def textilize(text, sanitize=False):
     """Format the text with Textile formatting