Solved

splitting full name string into first and last

Posted on 2004-08-28
1
211 Views
Last Modified: 2010-04-15
have a string that contains a full name... for example "john m doe".

need to put "doe" in a string called strLastName and "john m" in string called strFirstName. if the name was "john doe" (without the middle initial), then strLastName would be "doe", and strFirstName would be "john"

if there is a mr/ms/mrs/dr etc. in front of first name, then it should be placed in strFirstName...

please advise on the correct code... thanks!
0
Comment
Question by:loyaliser
[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
1 Comment
 
LVL 22

Accepted Solution

by:
cookre earned 500 total points
ID: 11923736
FirstSpace=FullName.IndexOf(" ");
LastSpace=FullName.LastIndexOf(" ");

FirstWord=FullName.Substring(0,FirstSpace);
LastWord=FullName.Substring(LastSpace+1);
Middle=FullName.SubString(FirstSpace+1,LastSpace-FirstSpace);

I leave it to you to check for:
* honorific or not
* no spaces
* just 1 space
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET MVC -Update model when click on <li> element 29 104
Return array 3 35
Visual Studio 2015 auto inserted code 12 89
VS C# how to design libary of functions 7 33
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

752 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