2022-08-29 16:29:03 +08:00

6 lines
191 B
Python

import re
phone = "2004-959-559 # this is a phone number"
num = re.sub('#.*$', "", phone)
print("the phone number is: ", num)
num = re.sub('\D', "", phone)
print("the phone number is: ", num)