diff --git a/regular-expressions.html b/regular-expressions.html index 5a75a44..b3f26d8 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').groups() +>>> phonePattern.search('800-555-1212').groups() ('800', '555', '1212', '') ->>> phonePattern.search('80055512121234').groups() +>>> phonePattern.search('80055512121234').groups() ('800', '555', '1212', '1234')
  1. Note the lack of ^ 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.