On Fri, Jan 29, 2010 at 7:24 AM, Jason King <[email protected]> wrote:
> Would this be the best way to get 'MO'?
> statematch = listfirst(stateetc, " ")
>
Kind of depends on what comes after the state abbreviation, but listfirst
with a space delimiter is certainly one way to go, as long as you know there
will always be a space following the state.
>
> That would make statematch equal to MO since it lists the first part of the
> string using the space as a delimiter. Or is that going to list the first
> part of the string AFTER the delimiter is found?
>
Easiest way to find out is to test. ;-) But yes, that will give you MO.
> If it's right as is, Then I could just test if it's length is 2 or not, and
> if it is, test if it just alphabetical characters.
>
> <CFIF listlen(statematch) eq 2 and isAlphabetical(statematch)>
>
> Now, there isn't an isalphatical function that I know of.
>
That's where a regex comes in, and this could handle the length check as
well. This tests for alphabetic characters:
<cfset ok = REFind("[[:alpha:]]", statematch) />
This would also handle the length bit:
<cfset ok = REFind("^[a-zA-Z]{2}$", statematch) />
So you could do:
<cfif REFind("^[a-zA-Z]{2}$", statematch)>
<!--- state is ok --->
<cfelse>
--
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 !!