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

Parse and reformat name from e-mail address

Status
Not open for further replies.

CSADataCruncher

Technical User
Feb 5, 2004
74
0
0
US
I am using Crystal Reports XI and am trying to pull a name from an e-mail address and then reverse it as follows:

e-mail field = first.last@domain.net

And I want to display the name on my report as last, first

I've tried split, right, left, mid... I know I'm close to a solution but I'm either getting just a portion of what I want or a numeric figure. Would someone be able to direct me to the correct code with a coding example? It would be greatly appreciated.

Thank you,
Peggy
 
Replace the @ with a period and it's easy to reference the array elements:

split(replace({EmailField},"@","."),".")[2] + ", " + split(replace({EmailField},"@","."),".")[1]
 
Brian,

Oh Thank you, Thank YOU! I had been looking and looking. This worked perfectly!

Peggy
 
Actually... almost perfectly. I forgot to mention that there are times when the e-mail address has an underscore rather than a dot. For instance first_last@domain.net. Is there a way to combine the formula you gave me with an if statement to determine if we are replacing a dot or an underscore?

Thank you,
Peggy
 
Nest an additional replace:

replace(replace({EmailField},"@","."),"_",".")

When I was writing my first post I was thinking "Boy is she lucky all her email addresses have the same format...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top