Match numbers



examples/regex/match_numbers.py
import re

line = 'There is a phone number 12345 in this row and an age: 23'

match = re.search(r'\d+', line)
if match:
    print(match.group(0))  # 12345

Use raw strings for regular expression: r'a\d'. Especially because \ needs it.

It matches the first occurrence. Here we can see that the group(0) call is much more interesting than earlier.