Solved

how do i break down a string?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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

10 Experts available now in Live!

Get 1:1 Help Now