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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stripping text 1

Status
Not open for further replies.

EscapeUK

Programmer
Jul 7, 2000
438
GB
I have a field which I pull back from the DB. The field contains peoples first names. Eg Ruth Lucy
Andrew Simon

How do I only display the first part
 
to display the first word of a string,:

If Instr({StringField}," ")=0 then {StringField} else
Left({StringField},Instr({Stringfield}," ")-1)

The first statement is required in case there is only one word in the string. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
dgillz is dead on.

Try to convince the owner of the table to separate the first and last names, because using the instr will likely result in some errors as there may be names like:

Father Woody Allen
Dr. Norman Rockwell
Billy Bob Thorton

The first 2 won't get the name at all, the latter will be incomplete.

It's worse for extracting last names, as in:

Billy Bob Thorton III

I developed extensive list correction logic years ago, and it's very complex and requires extensive name reference tables to improve quality.

-k kai@informeddatadecisions.com
 
I think Andrew's database has already separated first and last name fields. The 'Ruth Lucy' example looks like christian and middle names.
 
Ahhh, right, dgillz, I overlooked the part of his post that said FIRST name...

<slamming forehead into monitor as proper pennance>

So the only part that may bite him is the embedded middle name vs. compound first names, or the aforementioned Dr., etc.

-k kai@informeddatadecisions.com
 
If you're using 8 or 8.5 you could use the split function and just return the first member of the array:

split({StringField},&quot; &quot;)[1]

Save worrying about the error checking Andrew Baines
Chase International
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top