import re phonePattern = re.compile(r'^(d{3})D+(d{3})D+(d{4})D+(d+)$') phonePattern.search('000 888 1234 1234').groups() print phonePattern.search('000-888-1234-1234').groups() print phonePattern.search('00088812341234') print phonePattern.search('000-888-1234')
Name (required)
email (will not be published) (required)
Website