title: Javascript UK postcode regex
body: <p>I have a javascript regex which validates UK postcodes. It works well, but it doesn't take into account that some people write it with spaces in the middle and others don't. I've tried to add this but cant work it out :S UK postcodes are mainly 2 letters followed by 1 or 2 numbers, optional whitespace &amp; 1 number and 2 letters.</p>
  
  <p>Here is my regex which validates postcodes without spaces: </p>
  
  <pre><code>[A-PR-UWYZa-pr-uwyz0-9][A-HK-Ya-hk-y0-9][AEHMNPRTVXYaehmnprtvxy0-9]?[ABEHMNPRVWXYabehmnprvwxy0-9]?{1,2}[0-9][ABD-HJLN-UW-Zabd-hjln-uw-z]{2}|(GIRgir){3} 0(Aa){2})$/g
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I changed the regex as I realised one group was missing lowercase chars.</p>