I would extract all the numbers contained in a string. Which is the better suited for the purpose, regular expressions or the isdigit() method?
isdigit()
Example:
For phone numbers you can simply exclude all non-digit characters with \D in regex:
import re phone_number = '(619) 459-3635' phone_number = re.sub(r"\D", "", phone_number) print(phone_number)