Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how do i break down a string?

Posted on 2004-10-18
2
Medium Priority
?
195 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 400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline

824 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