How to Extract Numbers from a String in Python
The following example code shows how to extract numbers from a string in Python:
import re
text = "240a hello world example 10 14"
numbers = re.findall(r'\d+', text)
print("numbers =", numbers)
Output:
numbers = ['240', '10', '14']