Poco Script FAQ - Parsing address lines

Poco Script FAQ - Parsing address lines

Q: I have a line like this: RANCHO SANTA MARGARITA, CA, 92688, US I'm looking to yank out city, then state, then zip, then country? I've tried a half dozen different items but can pull it off. Any ideas would be appreciated.
 
A: Provided:
  1. The order of the fields will always be city, state, postal code and country,
  2. You can identify the line containing this information,
  3. You have a known delimiter (comma) between the fields
Then it is relatively easy to separate them using a combination of "GetLine", "StringPos" and "ChopString" commands. If any fields are missing you may also want to use various techniques to determine which is. These would typically involve "IsNumber", "CharCount" and the following technique to determine if a string is entirely composed of alphabetic characters:

set $a "abcdefghijklmnopqrstuvwxyz"

Then use the ^ comparison to determine if characters are present in the string.

Note: You must either convert the string you are comparing to lower case before using the "^" operator or include the upper case equivalents in $a. You may also, depending on your circumstance, want to include a blank character in $a.

Flash: There is a much easier way to do this provided the only commas in the string are those that separate the individual components. If this is the case the ReadCSV command can be used:

ReadCSV $address-info $address-line This will result in each portion of the address being placed as a separate line in multi-line variable $address-info.