diff --git a/regular-expressions.html b/regular-expressions.html index a89fc30..5a75a44 100755 --- a/regular-expressions.html +++ b/regular-expressions.html @@ -384,9 +384,9 @@ AttributeError: 'NoneType' object has no attribute 'groups' >>> phonePattern = re.compile(r'(\d{3})\D*(\d{3})\D*(\d{4})\D*(\d*)$') ① >>> phonePattern.search('work 1-(800) 555.1212 #1234').groups() ② ('800', '555', '1212', '1234') ->>> phonePattern.search('800-555-1212') ③ +>>> phonePattern.search('800-555-1212').groups() ③ ('800', '555', '1212', '') ->>> phonePattern.search('80055512121234') ④ +>>> phonePattern.search('80055512121234').groups() ④ ('800', '555', '1212', '1234')
^ in this regular expression. You are not matching the beginning of the string anymore. There’s nothing that says you need to match the entire input with your regular expression. The regular expression engine will do the hard work of figuring out where the input string starts to match, and go from there.