--- /dev/null
+# various functions which works on headers
+import re
+
+def cleanup_subject(subject_str):
+ """Returns a cleaned up string.
+ For instance, 'Re: Re: Re: Birthday party' becomes 'Birthday party'"""
+
+ cleanup_regexp = "^((Re:|RE:|fwd:|FWD:)\s+)+"
+ return re.sub(cleanup_regexp, "", subject_str)
+
--- /dev/null
+import unittest
+import kite.headers as headers
+
+class TestCleanup(unittest.TestCase):
+ def test_subject_cleanup(self):
+ s = headers.cleanup_subject("Your question")
+ self.assertEqual(s, "Your question")
+
+ s = headers.cleanup_subject("Re: Re: Your question")
+ self.assertEqual(s, "Your question")
+
+ s = headers.cleanup_subject("Re: RE: FWD: Your question")
+ self.assertEqual(s, "Your question")