2022-08-29 18:09:45 +08:00

6 lines
192 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)