import re
example_str = "Here is a example number: 1234. Here is another: 5678"
number = re.findall("d+", example_str) # Get list of numbers in string
# d+ -> matches 1 or more (+) digits appearances in string
string = "I am 14 years old"
for i in string.split():
if i.isdigit():
print(i)
print()
from itertools import groupby
my_str = "hello 12 hi 89"
l = [int(''.join(i)) for is_digit, i in groupby(my_str, str.isdigit) if is_digit]