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