Here is a code snippet to strip tags and leading and trailing whitespace

 

def remove_html_tags text):
        """Remove html tags from a string"""
        clean = re.compile('<.*?>')
        ntxt = re.sub(clean, '', text )
        return ntxt.strip()

 

Leave a Reply