I want to write a simple regular expression in Python that extracts a number from HTML. The HTML sample is as follows:
Your number is 123
import re found = re.search("your number is (\d+)", "something.... Your number is 123 something...") if found: print found.group()[0]
Here (\d+) is the grouping, since there is only one group [0] is used. When there are several groupings [grouping index] should be used.
[0]
[grouping index]