0
why is the phone_pattern getting matched but phone_patt isnt??i think \1 refers to group 1...am i wrong??
import re no = "345-678-091" phone_pattern = re.compile('\d{3}-\d{3}-\d{3}') phone_patt = re.compile("(\d{3})-\1-\1") print(phone_pattern.search(no)) print(phone_patt.search(no))
1 Resposta
+ 3
"(\d{3})-\1-\1" will match if it finds three digits followed by a hyphen and then the same three digits again, a hyphen and the same three digits again.
It won't match 345-678-091 but it would match 345-345-345.