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

Extract string after @

Status
Not open for further replies.

sc00byd00

Programmer
May 4, 2007
3
NL
Dear wizzkids
Ive done a fair share of searching this forum for a solution to my problem.
What i need is the 3 character starting behind the @.
This is how the data is delivered (always in this format)

name_of_client@dbb.com

I want to extract the 3 characters behind the @.

Can anyone help me out or point me in the right direction?
Maybe us ubound or...?
 
Try something like
Code:
if ubound(split({your.field},"@") = 2 
then Left(split({your.field},"@")[2]), 3)
else "Invalid " & {your.field}
Always wise to have some check for bad data.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I'd use the Split function to break off everything after (and including) the "@", then the Right function to get the 3 characters you need.

I think this should do it:

Right(Split(FieldName, "@", 1), 3)

Simon

"I do not have to forgive my enemies. I have had them all shot."
- Ramon Maria Narvaez
 
Ah, it seems I misunderstood - ignore my post, Madawc has the right (and better) answer.

Simon

"I do not have to forgive my enemies. I have had them all shot."
- Ramon Maria Narvaez
 
hmm cant get it to work get am message saying the ) is missing :|
 
Top line of code:

if ubound(split({your.field},"@")[red])[/red] = 2
then Left(split({your.field},"@")[2]), 3)
else "Invalid " & {your.field}

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Thanks alot guys it works like a charm now.
ps. you guys respond quickly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top