title: Complex Regex Pattern for Postcodes
body: <p>I currently have a regex pattern to only allow 'LL' UK postcodes and I use it with parsley JS with the 'pattern' tag. </p>
  
  <pre><code>data-parsley-pattern="/^[L]{2}[0-9][0-9A-Z]? ?[0-9][A-Z]{2}$/"
  </code></pre>
  
  <p>I now need to have a complex regex that would allow all 'LL' postcodes and certain 'CH' postcodes.</p>
  
  <p>Can someone please tell me what this would look like? It's way too complex for me. </p>
  
  <pre><code>CH1 6B &lt;---- 1 letter after the B
  CH1 6Q &lt;---- 1 letter after the Q
  CH4 9A &lt;---- 1 letter after the 0
  CH4 9B &lt;---- 1 letter after the 0
  CH4 0 &lt;---- 2 letters after the 0
  CH5 &lt;---- All variations like the 'LL'regex  [0-9][0-9A-Z]? ?[0-9][A-Z]{2}
  CH6 &lt;---- All variations like the 'LL' regex  [0-9][0-9A-Z]? ?[0-9][A-Z]{2}
  CH7 &lt;---- All variations like the 'LL' regex  [0-9][0-9A-Z]? ?[0-9][A-Z]{2}
  CH8 &lt;---- All variations like the 'LL' regex  [0-9][0-9A-Z]? ?[0-9][A-Z]{2}
  </code></pre>
  
  <p>The idea is if the postcode starts with 'LL' carry on using the normal regex, if the postcode starts with CH use a different pattern for everything after 'CH'</p>
  
  <p>Is this even possible? </p>