Open this example in the interactive library
Source code
import re
print(re.findall(r'\d+', 'Order 12 has 3 items'))Sample output
['12', '3']

Extract all integers. A self-contained example using the Python standard library.
Open this example in the interactive library
import re
print(re.findall(r'\d+', 'Order 12 has 3 items'))['12', '3']