Expand my Community achievements bar.

SOLVED

Extract name from email address

Avatar

Level 3

Is there any way to extract the name from an email address e.g. firstname.lastname@domain.com so that we can pull out the firstname and lastname and enter them into the name fields? I can't see anyway to do this in a query or function. There is a GetEmailDomain but not one for the name. Wondering if it's possible to use another function such as LPad?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @michaelwilding,

 

Try expression something below will give the first name,

 

Substring(Substring(@email,0,Charindex(@email,"@")), 0, Charindex(@email,"."))

 

Similar way you can get the last name.

 

Thanks, Sathees

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @michaelwilding,

 

Try expression something below will give the first name,

 

Substring(Substring(@email,0,Charindex(@email,"@")), 0, Charindex(@email,"."))

 

Similar way you can get the last name.

 

Thanks, Sathees

Avatar

Level 3

Thank you, that works well. Just putting this here for reference for anybody else. I used the following in an Enrichment node:

 

First name: Smart(Substring(Substring(emailfield,0,Charindex(emailfield,"@")), 0, Charindex(emailfield,".")) )

 

Last name: Smart(Substring(Substring(emailfield,0,Charindex(emailfield,"@")), Charindex(emailfield,".")+1, Charindex(emailfield,"@")) )

 

The Smart() capitalises the first letter of each name. Don't forget the data then needs to be updated in the database once you have enriched the incoming data.