On Thu, Jan 28, 2010 at 1:03 PM, Jason King <[email protected]> wrote:

> 1. Given String like 'St. Louis, MO adsfadf'
>
> Trim any space after first comma, check first and second position for
> alphabetical, check if 3rd position exists, check third position for space"
>

You can leverage more of the list functions here I'd think. ListLen() will
tell you if the stuff after the comma is > 2 characters.

This gives you "St. Louis":
city = ListFirst(foo)

This gives you "MO adsfasf":
stateEtc = ListLast(foo)

This tells you if stateEtc is > 2 characters--not th:
<cfif ListLen(stateEtc) gt 2>
    <!--- do whatever you need to do here (not sure what that is) --->
</cfif>

You can also use space as a delimiter to get stuff after the state
abbreviation:
<!--- get state from stateEtc --->
<cfset state = ListFirst(stateEtc, " ") />

I'm not totally clear what order you're wanting to do things in, so I'm
really just pointing out more of what you can do with the list functions.
And of course this doesn't get into what you could do with regular
expressions if you were so inclined.


>
> 2. Given String like 'St. Louis, Missouri adsfadf'
>
> Get string after comma, remove space after comma.
>


This gives you "Missouri adsfadf" and removes the space:
Trim(ListLast(foo))


> Parse out first part of string (using spaces as delimiter), check if match.
> If not parse out first and second part of string (for cases like 'north
> carolina') check if match.
>

Is the adsfasf stuff always going to be numbers? If so you could use a regex
and narrow things down more easily.


>
> ex  'St. Louis, Missouri adsfasf' yields 'Missouri' and would yield a
> match.
> ex. 'St. Louis, West Virginia' yields 'west' and does not find match. 2nd
> attempted yields 'West Virginia' and does find match.
>


If there's any regularity to the stuff after the state name you could do
this more efficiently than having to check twice.

-- 
Matthew Woodward
[email protected]
http://blog.mattwoodward.com
identi.ca/Twitter: @mpwoodward

Please do not send me proprietary file formats such as Word, PowerPoint,
etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html

-- 
Open BlueDragon Public Mailing List
 http://www.openbluedragon.org/   http://twitter.com/OpenBlueDragon
 mailing list - http://groups.google.com/group/openbd?hl=en

 !! save a network - please trim replies before posting !!

Reply via email to