I am using python 3.6, working on "Automate the Boring Stuff" course and trying to learn how to use VERBOSE mode in Regex. When the following code is executed, somehow the print result is:
[('123-', ''), ('415-', ''), ('905-', '')]
Can someone tell me what I am doing wrong? I would like the code to return both phone numbers in the string.
import re
phoneNum = re.compile(r'''
(\d\d\d-)| # area code without parentheses but with dash
(\(\d\d\d\) ) # -or- area code with parentheses and no dash
\d\d\d # first 3 digits
- # second dash
\d\d\d\d # last 4 digits''', re.VERBOSE)
print(phoneNum.findall('(415) 123-2342 and 415-905-1234 are the numbers.'))