extracting numbers from string in python code example
Example 1: python extract all numbers from string re
>>> str = "h3110 23 cat 444.4 rabbit 11 2 dog"
>>> [int(s) for s in str.split() if s.isdigit()]
[23, 11, 2]
Example 2: extract numbers from list of strings python using regex
new_list = [int(item) for sublist in a for item in sublist if item.isdigit()]