I extracted a raw string from a Q&A forum. I have a string like this:
s = 'Take about 2 + <font color="blue"><font face="Times New Roman">but double check with teacher <font color="green"><font face="Arial">before you do'
I want to extract this substring "<font color="blue"><font face="Times New Roman">" and assign it to a new variable. I am able to remove it with regex but I don't know how to assign it to a new variable. I am new to regex.
import re
s1 = re.sub('<.*?>', '', s)
This is removes the sub but I'd like to keep the removed sub for the record, ideally reassign it to a varialbe.
How can I do this? I may prefer regular expressions.