title: Extract Alberta (Canada) postal code through regular expressions in python
body: <p>I want to extract postal codes of Alberta (Canada) region from an address string. </p>
  
  <p>For example:</p>
  
  <pre><code> addr = '12345-67 Ave, Edmonton, AB T1A 2B3, Canada'
  </code></pre>
  
  <p>Should extract <code>T1A 2B3</code>.</p>
  
  <p>The regular expression to match the postal code is <code>[T]\d[A-Z] *\d[A-Z]\d</code>. However, I do not know that given an entire address, how can I extract only the postal code? I guess it has to do something with backreferences <code>()</code> but I cannot figure it out.</p>
  
  <p>How can I achieve this in Python?</p>