Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract name field 1

Status
Not open for further replies.

ncchish

Programmer
Jul 29, 2002
86
US
Does anyone know how to extract names from a name field? I have been able to extract the first name but not the last name. I can get part of it including the suffix/designation. The name field is set up like- this (spaces no commas between the fields).

"first name/initial" "middle name/initial" "last name" "suffix or designation".
FOR EX. - JEFF J DOE JR CLU
- J JOE DOE

If I can figure out how to get just the last name then I think I can get the others too. I want to be able to split this database name up separately. Any help is appreiciated; I'm using Crystal 8.5.

Thanks in advance!

ncchish
 
The name field was poorly designed, an intelligently designed table will generally have:

Salutation
First name
Middle Name
Last Name
Suffix

as all seperate fields.

There isn't a way to reliably extract poorly designed data, although you can try numerous if conditions.

As an example, take these names:

Finn Jorgensen (no middle name)
Oscar De La Hoya
George Dubuya Bush

There are no rules that would know how to extract the last name as in the first case, it's the second word, the second name it's the 2nd thru 4th words, and in the last case it's the third word.

Fire the architect, that should help going forward.

Here's an example of how to get the names:

whileprintingrecords;
stringvar array TheNames := split({table.field}," ");
numbervar NumberOfNames := ubound(TheNames);

Now the names are boken apart in the TheNames array, and can be individually extracted using something like:

TheNames[1]

Where the [1] is which word.

And you can get the count of the words using NumberOfNames for your coditional guessing of the names...

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top