Hi Guys,
I have some strings that need to be parsed, and I'm having trouble figuring out the best way to do it. I'll try and best explain what I need and hopefully someone can point me in the right direction. My goal is to be able to take a user inputted string that contains location info (city, state, zip) and parse each element out seperately. Granted, this contains alot of guess work (could this string be a city name? yes/no), but I still need to have something in place. If anybody could explain in CFML code how to achieve each of the parse jobs listed below, I would be very grateful!!!
First, let's assume the string being worked with is a variable named 'string'
Parse Job 1 (find zip code)
-Search 'string' to find zip code.
-Find segment where first character is numeric and length = 6
-Check segment that all 6 characters are numeric
-set variable 'zipstring' equal to segment
-set variable 'string' equal to 'string - segment' so that future operations on string exclude zip code
ex. original string = "st. louis, MO 63101"
ex. updates string = "st. louis, MO"
Parse Job 2 (find state abbr ex. MO)
-Search 'string' to find State Abbreviation
-findsegment where first char is "," (comma) and following string is no more than 3 characters
-remove any spaces from segment ", IL" becomes ",IL"
-remove comma from segment ",IL" becomes "IL"
Parse Job 3 (find state abbr ex. MO)
-findsegment where first char is Alphabet and Length = 2
-Check segment if all char is alphanumeric
I have some strings that need to be parsed, and I'm having trouble figuring out the best way to do it. I'll try and best explain what I need and hopefully someone can point me in the right direction. My goal is to be able to take a user inputted string that contains location info (city, state, zip) and parse each element out seperately. Granted, this contains alot of guess work (could this string be a city name? yes/no), but I still need to have something in place. If anybody could explain in CFML code how to achieve each of the parse jobs listed below, I would be very grateful!!!
First, let's assume the string being worked with is a variable named 'string'
Parse Job 1 (find zip code)
-Search 'string' to find zip code.
-Find segment where first character is numeric and length = 6
-Check segment that all 6 characters are numeric
-set variable 'zipstring' equal to segment
-set variable 'string' equal to 'string - segment' so that future operations on string exclude zip code
ex. original string = "st. louis, MO 63101"
ex. updates string = "st. louis, MO"
Parse Job 2 (find state abbr ex. MO)
-Search 'string' to find State Abbreviation
-findsegment where first char is "," (comma) and following string is no more than 3 characters
-remove any spaces from segment ", IL" becomes ",IL"
-remove comma from segment ",IL" becomes "IL"
Parse Job 3 (find state abbr ex. MO)
-findsegment where first char is Alphabet and Length = 2
-Check segment if all char is alphanumeric