title: Automate the Boring Stuff Chapter 7: Regular Expressions - phone number and email extractor only extracting phone numbers
body: <p>I am following the book and am pretty sure I copied the code verbatim. When I copy the Contact Us page on the publisher website (nostarch.com/ContactUs) and run it through the program, it outputs all the phone numbers but no email addresses.</p>
  
  <p>I made sure the code was copied correctly. I thought it may be an issue with the print function so I tried pasting the result into a text file and the email addresses were still nowhere to be found.</p>
  
  <pre><code>import pyperclip, re
  
  # email regex
  emailRegex = re.compile(r'''(
      [a-zA-Z0-9._%+-]+  # username
      @                  # at symbol
      [a-zA-Z0-9.-]+     # domain name
      (\.[a-zA-Z]{2-4})  #dot-something
      )''', re.VERBOSE)
  
  # find matches in clipboard text
  text = str(pyperclip.paste())
  matches = []
  for groups in phoneRegex.findall(text):
      phoneNum = '-'.join([groups[1], groups[3], groups[5]])
      if groups[8] != '':
          phoneNum += ' x' + groups[8]
      matches.append(phoneNum)
  for groups in emailRegex.findall(text):
      matches.append(groups[0])
  
  # copy results to the clipboard
  if len(matches) &gt; 0:
      pyperclip.copy('\n'.join(matches))
      print ('Copied to clipboard:')
      print ('\n'.join(matches))
  else:
      print('No phone numbers or email addresses found.')
  </code></pre>
  
  <p>I expect to get the result:</p>
  
  <pre><code>Copied to clipboard:
  800-420-7240
  415-863-9900
  415-863-9950
  info@nostarch.com
  media@nostarch.com
  academic@nostarch.com
  help@nostarch.com
  </code></pre>
  
  <p>but only got this:</p>
  
  <pre><code>Copied to clipboard:
  800-420-7240
  415-863-9900
  415-863-9950
  </code></pre>