Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 9 Jahren, 2 Monaten
Letzter Beitrag:
vor 9 Jahren, 2 Monaten
Beteiligte Autoren:
Fabrice Harari, Joel

How to pull apart an address string

Startbeitrag von Joel am 15.06.2009 19:17


In a WebDev project, I have imported a dbase with an address string that looks like this:

186 Center Street
Manchester, CT 06040

There appears to be some sort of a CR after the street address as it always populates 2 lines.

I need to pull that address apart to drop the pieces into separate fields -
Address (with no CR)
Zip (most are the 6 digit variety, but not all)

Does anyone have a bit of code that ca reliably do this?


Hi Joel

it depends of several things (and that's why software extracting addresses automatically, like quickbook, often are making a poor job out of it)

By example:
- Is the zipcode always at the end?
- Is the zipcode always there?
- Is there always a state?
- is there always a "," after the city?
- are there always ONLY 2 lines in the address?

If the answer is YES to all these questions then the code would be something like that (not tested so bugs are probable)
sAddress is string
sLine2 is string
sCity is string=Extractstring(sLine2,1,",")
sZip is string=Extractstring(sLine2,1," ",FromEnd)
sState is string=Extractstring(sLine2,2," ",FromEnd)

If the answer is no to any of the questions above then you must have code testing the actual formatting of the address to decide in what case you are (with or without zip code by example), and then use the coding appropriate in each case.

Best regards

von Fabrice Harari - am 15.06.2009 20:46
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.