Jan-02-2022, 07:04 AM
Hi,
I would like my code to return '(415)'. What am i doing wrong?
I would like my code to return '(415)'. What am i doing wrong?
phoneNumRegex=re.compile(r'(\(\d\d\d\))(\d\d\d-\d\d\d\d)')
mo=phoneNumRegex.search('My phonenumber is (415) 555-4242.')
mo.group(1)
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
mo.group(1)
AttributeError: 'NoneType' object has no attribute 'group'
