title: PostgreSQL: Match Email Addresses With or Without Subdomains
body: <h1>Scenario</h1>
  <p>For most of its history, my company used subdomains in the email addresses, mostly by state, but others had division subdomains. A few examples of what we had include:</p>
  <pre><code>mo.widgits.com
  sd.widgits.com
  va.widgits.com
  nhq.widgits.com
  gis.widgits.com
  tech.widgits.com
  </code></pre>
  <p>...and so on.</p>
  <h1>New Paradigm</h1>
  <p>A few years ago, top management decided that they wanted us all to be one happy family; as part of this cultural realignment, they changed everyone's email addresses to the single domain, in the format of <code>firstname.lastname@widgits.com</code>.</p>
  <h1>Present Challenges</h1>
  <p>In many of our corporate databases, we find a mixture of records using either the old format and the new format. For example, the same individual might have <code>porky.pig@widgits.com</code> in the employee system, and <code>porky.pig@in.widgits.com</code> in the training system. I have a need to match individuals up among the various systems regardless of which format email is used for them in that system.</p>
  <h1>Desired Matches</h1>
  <pre><code>porky.pig@in.widgits.com = porky.pig@widgits.com -&gt; true
  mary.poppins@widgits.com = mary.poppins@nhq.widgits.com -&gt; true
  bob.baker@widgits.com = bob.barker@gis.widgits.com -&gt; false
  </code></pre>
  <h1>How to Accomplish This?</h1>
  <p>Is there a regex pattern that I can use to match email addresses regardless of which format they are?  Or will I need to manually extract out the subdomain before attempting to match them?</p>