title: How to correct unbalanced parenthesis error in regular expression?
body: <p>I am learning regular expression through Al Sweigart's automate the boring stuff course on udemy, lesson 29. I get an error saying "unbalanced parenthesis at position 414 (line 12, column 1)" </p>
  
  <p>The code is meant to pull phone numbers and email addresses using regular expression.</p>
  
  <p>I have tried counting the parenthesis and taking the top and bottom parenthesis out for the email regex.</p>
  
  <pre><code>#! python3
  
  import re, pyperclip
  
  # Done - TODO: create a regex object for phone numbers
  phoneRegex = re.compile(r'''
  # Types of number 415-555-0000, 555-0000, (415) 555-0000, 555-0000 ext 12345,
  # ext. 12345, x12345
  (
  ((\d\d\d) | (\(\d\d\d\)))?            # area code (optional)
  (\s|-)            # first separator
  \d\d\d            # first 3 digits
  -            # separator
  \d\d\d\d            # last 4 digits
  ((ext(\.)?\s)|x)           # extension word part (optional)
  (\d{2,5}))?             # extension number part (optional)
  )
  ''', re.VERBOSE)
  
  # TODO: Create a regex for email addresses
  emailRegex = re.compile (r'''
  # some.+_thing@(\d{2,5}))?.com
  
  [a-zA-Z0-9_.+]+         # name part - created non default regular   expression class
  # to capture any character a-z lowercase, A-Z upper case, numbers 0-9, characters _.+
  @        # @ symbol
  [a-zA-Z0-9_.+]+        # domain name part
  
  ''', re.VERBOSE)
  
  # TODO: Get the text off the clipboard
  text = pyperclip.paste()
  
  # TODO: Extract the email/phone from this text
  extractedPhone = phoneRegex.findall(text) # creates one string for each group ()
  # Make sure desired regex is all in one group ()
  extractedEmail = emailRegex.findall(text)
  
  print (extractedPhone)# temporary print function to see if code works
  print (extractedEmail)
  </code></pre>
  
  <p>Gives this error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):
    File "C:\Users*\Desktop\Education\computer science\automate the boring   stuff\programs\lesson 29 phone and email regex.py", line 18,
    in 
        ''', re.VERBOSE)
         File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\re.py", line
    234, in compile
          return _compile(pattern, flags)
         File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\re.py", line
    286, in _compile
          p = sre_compile.compile(pattern, flags)
         File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\sre_compile.py",
    line 764, in compile
          p = sre_parse.parse(p, flags)
         File "C:\Users*\AppData\Local\Programs\Python\Python37\lib\sre_parse.py",
    line 944, in parse
         raise source.error("unbalanced parenthesis")
         re.error: unbalanced parenthesis at position 414 (line 12, column 1)</p>
  </blockquote>