Source Code:
(back to article)
import re string = "The cost is $120 and the tax is $20.5" numbers = [float(num) for num in re.findall(r'[\d.]+', string)] print(numbers) # Output: [120.0, 20.5]
Result:
Report an issue