Solved

how do i break down a string?

Posted on 2004-10-18
2
163 Views
Last Modified: 2013-12-24
hi,

i am given name strings from a xml feed similar to as follows:
Mr. Joe Smith
or
Mrs. Jane Doe
or
Jack Clark

i need to break the string down into 3 strings: first name, last name, and title. the last name will always be leftmost characters ending at the first space (this may be wrong sometimes if they have  a last name with 2 words (i.e. von houghton), but thats ok). the first name will be characters from the first space in front of the last name to the beggining of the string or the '.' period if there is one. if there is a period, the characters preceding it will be the title, if no period i can assume there is no title. any ideas on how i can do this?
0
Comment
Question by:soadfan
2 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 100 total points
ID: 12342798
<CFSET xmlfeed = "Mr. Joe Smith">

<CFSET title = "">
<CFSET firstname = xmlfeed>
<CFSET lastname = LISTLAST(xmlfeed," ")>

<CFIF RIGHT(LISTFIRST(xmlfeed," "),1) eq ".">
      <CFSET title = LISTFIRST(xmlfeed," ")>
      <CFSET firstname = LISTDELETEAT(firstname,1," ")>
</CFIF>

<CFSET firstname = LISTDELETEAT(firstname,LISTLEN(firstname," ")," ")>
0
 

Author Comment

by:soadfan
ID: 12342897
that works perfect, thanks!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now