On Fri, Jan 29, 2010 at 10:57 AM, Jason King <[email protected]> wrote:
> 1. What if the string is like 'St. Louis, MO'
> - Will listfirst(stateETC, " ")> still work? There's no space at the end.
> So would it just grab the whole string?
>
In that case you'd end up with "St. Louis," which INCLUDES the comma. It
would still use space as a delimiter.
General comment, and I'm not making this to be snide or anything along those
lines, but because I think this is the way people can grow best as
programmers. You should really just experiment with all this stuff and see
what happens. The question you asked above could be answered by running the
code and seeing the result. Again, I'm not saying this to be rude and I'm
more than happy to help as always, but I know for myself things stick a lot
more when I hack away at code for a while and see what happens. The whole
"teach a man to fish" thing. ;-)
>
> Or should I do like
>
> <CFSET stateabbvmatch = trim(listlast(string))>
> <CFSET spaceindex = Find(" ", stateabbvmatch)>
> <CFIF spaceindex = 3>
> <CFSET stateabbvmatch = listfirst(stateabbvmatch, " ")>
> </CFIF>
> <cfif REFind("^[a-zA-Z]{2}$", stateabbvmatch)>
>
I wouldn't go through all the machinations above unless you have to. Which
format do you get things in? I'm not sure you ever completely clarified
that.
Can you guarantee you'll have a comma after the city name or not? If not,
then I'd probably use space as a delimiter and eliminate the last comma from
city name if it exists, which you can do by using Find or charAt to see if
there's a comma at the end, or even by doing ListFirst("St. Louis,") which
would give you "St. Louis" without the comma and would also work if there is
no comma.
--
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 !!