title: How to correctly match UK postcodes by prefix?
body: <p>I have a number of restaurants who all deliver to certain postcode areas in London, for example:</p>
  
  <ul>
  <li><code>EC1</code></li>
  <li><code>WC1</code></li>
  <li><code>WC2</code></li>
  <li><code>W1</code></li>
  </ul>
  
  <p>When someone searches for a restaurant that delivers to their home, they enter their full postcode.</p>
  
  <p>Some people enter the postcode correctly with the space, some of them just enter all letters and numbers attached, without a space separator. To harmonize things, I remove any space in the postcode before attempting a match.</p>
  
  <p>So far, I used to match the postcode to the prefixes by just checking if it starts with the prefix in question, but then I realized that this is not foolproof:</p>
  
  <ul>
  <li><code>WC1E123</code> => correct match for <code>WC1</code></li>
  <li><code>W1ABC</code> => correct match for <code>W1</code></li>
  <li><code>W10ABC</code> => incorrect match for <code>W1</code>, should only match the <code>W10</code> prefix</li>
  </ul>
  
  <p>How can I know, <strong>given a full postcode with no space</strong>, if it <strong>matches a given prefix</strong>, while not failing the <code>W1</code> / <code>W10</code> test above?</p>
  
  <p>Is there any solution at all to the problem, that would not involve forcing the customer to enter the postcode with the space at the correct position?</p>