Is there a formula/function to split data out of one cell?

Hello all ~

I copied a long list of first name, last name and email addresses out of an email. I want to be able to separate the data into 3 columns - first name, last name, email address. In Numbers, I managed to get the data into one column (A1) but it is one long column that looks like this:


Column A

first name1 last name1 <email address1>

first name2 last name2 <email address2>

etc.


Is there any way to separate the individual data I need without having to go through manually and separating everything? It's a pretty long list. There there isn't anything separating the first name from the last name and the email address is only separated by the arrows <> as shown above.


So it looks like this: Peyton M <***.com>


I hope I explained this clearly. I am not a function/formula guru so if you need more information let me know.


Thanks for your help.

Judy



[Edited by Moderator] 


MacBook Air 13″, macOS 13.2

Posted on Nov 9, 2023 5:13 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 9, 2023 7:24 PM

I would like to amend my own post...

B2=IFERROR(REGEX.EXTRACT($A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*<?(.+)>?",1,1), "")

C2=IFERROR(REGEX.EXTRACT($A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*<?(.+)>?",1,2), "")

D2=IFERROR(REGEX.EXTRACT($A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*<?(.+)>?",1,3), "")



OK. I will explain a little about this approach...

There is another solution that uses string functions to locate the spaces between (the delimiter) each field. then you can use the left, mid and right functions to extract the fields. This option will not survive the what is there are two spaces or a tab.


The solution I am presenting uses "REGULAR EXPRESSIONS" for pattern matching in text.


Now I will break it into pieces:

"([A-Za-z]+) \s* ([A-Za-z]+) \s* <? (.+) >? "


([A-Za-z]+) means to look for 1 or more characters in the set A-Z, a-z. the parenthesis mean to capture the result in place 1


the \s* means to look for zero or more white space characters (white space is a space or tabs)


<? (.+) >? means to look for one or more of any character (the dot) surrounded by zero or one angle braces






14 replies
Question marked as Top-ranking reply

Nov 9, 2023 7:24 PM in response to Wayne Contello

I would like to amend my own post...

B2=IFERROR(REGEX.EXTRACT($A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*<?(.+)>?",1,1), "")

C2=IFERROR(REGEX.EXTRACT($A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*<?(.+)>?",1,2), "")

D2=IFERROR(REGEX.EXTRACT($A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*<?(.+)>?",1,3), "")



OK. I will explain a little about this approach...

There is another solution that uses string functions to locate the spaces between (the delimiter) each field. then you can use the left, mid and right functions to extract the fields. This option will not survive the what is there are two spaces or a tab.


The solution I am presenting uses "REGULAR EXPRESSIONS" for pattern matching in text.


Now I will break it into pieces:

"([A-Za-z]+) \s* ([A-Za-z]+) \s* <? (.+) >? "


([A-Za-z]+) means to look for 1 or more characters in the set A-Z, a-z. the parenthesis mean to capture the result in place 1


the \s* means to look for zero or more white space characters (white space is a space or tabs)


<? (.+) >? means to look for one or more of any character (the dot) surrounded by zero or one angle braces






Nov 9, 2023 7:07 PM in response to ledzepgirl

Try this... assuming that the data is in column A as shown in the following table:


select cell B2 and type (or copy and paste from here) the formula:

=REGEX.EXTRACT(A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*(.+)",1,1)


shorthand for this is:

B2=REGEX.EXTRACT(A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*(.+)",1,1)


then type return.

C2=REGEX.EXTRACT(A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*(.+)",1,2)

D2=SUBSTITUTE(SUBSTITUTE(REGEX.EXTRACT(A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*(.+)",1,3), ">", ""), "<", "")


To fill down:

select cells B2 thru D2, copy

select cells C2 thru the end of column D, paste


if you do not want to see errors for empty cells modify the formulas to "mask out" these errors use the following formulas:

B2=IFERROR(REGEX.EXTRACT(A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*(.+)",1,1), "")

C2=IFERROR(REGEX.EXTRACT(A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*(.+)",1,2), "")

D2=IFERROR(SUBSTITUTE(SUBSTITUTE(REGEX.EXTRACT(A2,"([A-Za-z]+)\s*([A-Za-z]+)\s*(.+)",1,3), ">", ""), "<", ""), "")


Then fill down using the copy and paste I presented earlier


Nov 10, 2023 4:23 PM in response to ledzepgirl

Judy,


the screenshot is a little helpful.


What I think is the following:

1) the contact info in the email is something like:

first1 last1 <email1>_TAB_first2 last2 <email2>_TAB_first3 last3 <email3>_TAB_first4 last4 <email4>


I know that may look complicated...

  • the fields within each group are separated (delimited) by spaces
  • each contact is separated (delimited) by tabs and
  • there are no line ending characters (return)


copy the list of emails from original email

paste into the app Text Edit

locate the first TAB (highlighted in grey in my screenshot)

select a TAB, copy

In the Find (menu item "Edit > Find and Replace…")

paste the tab you copied into the "Find" field


select that same TAB, type the return key

hold the shift key and type the back arrow once to select the RETURN, copy

in the Replace field, paste


click the segment "ALL"



select all and paste into Numbers:



that should do it

Nov 9, 2023 7:33 PM in response to Wayne Contello

Hi Wayne ~


Thank you so much! This worked great for the first contact. I can't figure out how to get the copy and paste part to work. But I think that my problem is that everything is contained in cell A2. I don't have each contact in their own cell (A2, A3, etc.). I am not sure if there is a formula or function to separate the contacts if they're all contained in one cell...? The problem is that the list is rather long so I'm hoping there is a much faster way to split the data that I need into the right columns.


Do you know of any formula that works for that?


I really appreciate your knowledge!

Nov 10, 2023 3:10 PM in response to Wayne Contello

Oh wow ~ that is really interesting. I had no idea. Thank you for sharing. When I was in junior high, we had a juke box (I'm dating myself) and it was filled with all Led Zeppelin songs. Sigh...the good ol' days. :)


As for the suggestion you gave me to go back and start again ~ it's still not working. The original data was from a gmail message. At one point, before I wrote this post, I was able to split the data but the contacts were place in their own columns. So I would still have had to go through and cut and paste. Here's a screenshot of what I mean:


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.

Is there a formula/function to split data out of one cell?

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