Extracting name from email address

I am trying to extract names from email addresses that are in the form:


firstname.lastname@gmail.com


LEFT(A1,(SEARCH(".",A1,start-pos)−1))


works for the first name, i.e. it returns 'firstname' from the above email address, but I can't work out how to extract the last name.


Can someone help with this?


Thanks,


Nick

Macbook Pro, Mac OS X (10.4.8)

Posted on May 30, 2015 4:31 AM

Reply
5 replies

May 30, 2015 5:50 AM in response to nick putman

Hi Nick,


I find it best to break a problem into small steps (that is how my brain works).

User uploaded file

I have added a Header Row for (guess what?) headings 😉.


Step 1. Change the email address to plain text (Column B) so it doesn't keep opening Mail every time you click on it.

Formula in B2

=PLAINTEXT(A2)


Step 2. Find the position of the dot between firstname and lastname. Formula in C2

=FIND(".",B2,1)


Step 3. (Your solution for first name). Formula in D2

=LEFT(B2,(SEARCH(".",B2,1)−1))


Step 4. Find the position of the @. Formula in E2

=FIND("@",B2,1)


Step 5. Find lastname. Formula in F2

=MID(B2,C2+1,E2−C2−1)


You can hide the intermediate columns.


Regards,

Ian.

May 30, 2015 6:15 AM in response to SGIII

Hi SG,


Nice! Your reply made me look again at FIND and SEARCH.

From the Function Browser:

The FIND function returns the starting position of one string within another.

The SEARCH function returns the starting position of one string value within another, ignoring case and allowing wildcards.


Either function seems to work in this case, but I found it useful to learn about case and wildcards.


Regards,

Ian.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Extracting name from email address

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.