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()
import re
s = "12 hello 52 19 some random 15 number"
# Extract numbers and cast them to int
list_of_nums = map(int, re.findall('d+', s))
print list_of_nums
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]