String Manupulation.

i have a variable #first_name# , which sometimes have content like "John F." and also "John". I need to extract First name and middle initial into different variables. How do I do that? Also I need to know how to manupulate CFSWITCH statement.  I need to assign codes for US states (AL->01, AR->02,CA->23,etc...)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nathan Stanford SrSenior ProgrammerCommented:

Variable First Name

      <title>Sample on How to get First Name and Middle Initial</title>
<body bgcolor="ffffff">

<cfset First_Name = "Nathan A">
<cfset First_Name1 = "Nathan">

<CFSET FirstName = #GetToken("#first_name#", 1," ")#>
<CFSET MI = #GetToken("#first_name#", 2," ")#>
<CFSET FirstName1 = #GetToken("#first_name1#", 1," ")#>
<CFSET MI1 = #GetToken("#first_name1#", 2," ")#>
<cfoutput>#FirstName# #MI#</cfoutput><br>
<cfoutput>#FirstName1# #M1I#</cfoutput>


<cfswitch expression="#STATE#">

      <cfcase value="01">
      <cfcase value="02">
      <cfcase value="23">


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nathan Stanford SrSenior ProgrammerCommented:
Copy the small file for figuring out how to do the first_name and save in as a file then browse it and it will show you that it works.

on cfswitch the code for each state goes in place of the two-digit name.
anushaAuthor Commented:
Thanks Nathans :-)

Nathan Stanford SrSenior ProgrammerCommented:
Your Welcome isn't ColdFusion Awesome.

I love it.

I work in the DFW Area in case someone is hiring.
anushaAuthor Commented:

since cfswitch does not work inside cfoutput tags , how would I do cfswitch in the middle of query?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.