Solved

how do i break down a string?

Posted on 2004-10-18
2
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

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…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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