programming-examples/python/Regular_Expression/Separate and print the numbers of a given string.py

7 lines
172 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
import re
# Sample string.
text = "Ten 10, Twenty 20, Thirty 30"
result = re.split("\D+", text)
# Print results.
for element in result:
print(element)