Python3 正则表达式 查找和替换 Python3 正则表达式match vs search Python3 First cgi 程序 Python3 正则表达式 查找和替换 #!/usr/bin/python3 import re phone = "2004-959-559 # This is Phone Number" # Delete Python-style comments num = re.sub(r'#.*$', "", phone) print ("Phone Num : ", num) # Remove anything other than digits num = re.sub(r'\D', "", phone) print ("Phone Num : ", num) Python3 正则表达式match vs search Python3 First cgi 程序