Solved

splitting full name string into first and last

Posted on 2004-08-28
1
207 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
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

22 Experts available now in Live!

Get 1:1 Help Now