I am scraping data from a website and the tag contains the text 'ANSWER (1)'. My goal is to extract just the '1' from the string using regular expressions in python.
Is there a simple way to go about doing this?
I am scraping data from a website and the tag contains the text 'ANSWER (1)'. My goal is to extract just the '1' from the string using regular expressions in python.
Is there a simple way to go about doing this?
Try this code:
import re
s = "ANSWER (1)"
print re.search(r".*\((\d)\)",s).group(1)