Context: I am removing HTML tags from strings, but for some reason some href tags are still showing up. To avoid this, I’d like to create another re.sub to remove these tags
For example this text:
<a href="/p76643761#p76643761active That's nice
Should be replace with empty string and output should just be That's nice,etc
Function I have (isn’t removing href tags for some reason)
def remove_html_tags(text):
text = re.sub('<[^<]+?>', '', text)
return text
Thank you all!
>Solution :
You could use <a href=\S+\s
def remove_html_tags(text):
return re.sub(r'<a href=\S+\s', '', text)