def strip_email_quotes(text):
 lines = text.splitlines()
 matches = set()
 for line in lines:
  prefix = re.match('^(\\s*>[ >]*)', line)
  if prefix:
   matches.add(prefix.group(1))
  else:
   break
 else:
  prefix = long_substr(list(matches))
  if prefix:
   strip = len(prefix)
   text = '\n'.join([ln[strip:] for ln in lines])
 return text

def strip_email_quotes ( text ) : lines = text . splitlines ( ) matches = set ( ) for line in lines : prefix = re . match ( '^(\\s*>[ >]*)' , line ) if prefix : matches . add ( prefix . group ( 1 ) ) else : break else : prefix = long_substr ( list ( matches ) ) if prefix : strip = len ( prefix ) text = '\n' . join ( [ ln [ strip : ] for ln in lines ] ) return text
strip leading email quotation characters (>) .