How to grab a number from inside a .html file using regex

Thomas Jollans thomas at
Sat Aug 7 21:03:21 CEST 2010

On 08/07/2010 08:51 PM, Νίκος wrote:
> On 7 Αύγ, 21:24, MRAB <pyt... at> wrote:
>> Use group capture:
>>      found = re.match(r'<!-- (\d+) -->', firstline).group(1)
>>      print(page_id)
> Worked like a charm! Thanks a lot!
> So match method here not only searched for the string representation
> of the number but also convert it to integer as well?
> r stand for retrieve the string here?

r"xyz" is a raw string literal. That means that backslash escapes are
turned off -- r'\n' == '\\n'

> and group?
> Wehn a regex searched a .txt file when is retrieving something for it
> always retrieve it as string right? or can get it as a number as well?

More information about the Python-list mailing list