1>>> str = "h3110 23 cat 444.4 rabbit 11 2 dog"
2>>> [int(s) for s in str.split() if s.isdigit()]
3[23, 11, 2]
4
1string = "abc123"
2# Method 1
3''.join(char for char in string if char.isdigit())
4
5#Method 2
6import re
7re.sub("[^0-9]", "", string)
1string = "I am 14 years old"
2for i in string.split():
3 if i.isdigit():
4 print(i)
5print()
6
1from itertools import groupby
2my_str = "hello 12 hi 89"
3
4l = [int(''.join(i)) for is_digit, i in groupby(my_str, str.isdigit) if is_digit]
5