Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you should clarify your usage scenario.</p> <p>Unless you're in a very, very limited scenario where you know that the addresses were entered following a strict schema, parsing addresses for content is an extremely hard problem to solve and, usually, quite futile (unless it's the <em>raison d'être</em> of your application).</p> <p>If you're limited to a particular country that has very specific conventions for writing addresses, then using these regex might get you 90% of the way.<br> However, as soon as you have to start accepting foreign addresses, you're screwed.<br> Even if you're a US-centric site, there is a good chance that you may have to be able to accept addresses from US citizen living abroad for instance.</p> <p>Again, it may be OK in a very narrow field, but it's almost always a bad idea to validate or split addresses that were not strictly validated and constrained at the time the user entered them.<br> When you do enforce some strict rules for users to enter their addresses, these end-up being inadequate in a small portion of cases, even in the best address validation components out there.</p> <p>Just a few things that mess up address parsing:</p> <ul> <li>postal codes (Zip codes) are sometimes placed before, after, or may even not exist at all.</li> <li>postal codes follow strict rules: a 10-digit Zip code is probably easy to spot as invalid, but what about a non-existent one? What about more codes such as those used in the UK for instance?</li> <li>What about a place like Hong Kong where you could write the address in either English, Traditional Chinese or Mandarin?</li> <li>What if it's perfectly fine to split your address and write it out of sequence?</li> <li>even if you're just parsing US addresses, there are at least a handfull of ways to describe a PO box: you can also use <em>poste restante</em>, <em>general delivery</em> and then need to add a 4-digit code to the Zip code, which would normally probably not be present at all...</li> </ul> <p><strong>Bottom line is</strong> </p> <p>If getting addresses in a parseable format is really important, be 100% sure that you can get all possible combinations right or you're going to have a percentage of failures that will mean frustrated users and loss sales.<br> If you don't have 100% case coverage then don't enforce strict rules on the user.<br> I can't count the number of websites I gave up purchasing from because they would require a Zip/Postal Code when the place I live in has none.</p> <p>Sorry for the rant, but I think it's important that people wanting to do address validation and parsing think hard about what they're getting themselves in.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload