Solved

how do i break down a string?

Posted on 2004-10-18
2
184 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

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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