Extracting first email in a field with multiple emails

This may have been covered, but I cannot find it. I have a field that has several emails in it. It is a lookup field I need to extract the first email in the list. Can someone help me with the formula?

Hi @Kirsten_Kern,

Instead of a Lookup field, use a Rollup field and use the ArrayJoin function
image

Then in your formula field use the following. Replace {Email Rollup} with your reference.

REGEX_EXTRACT({Email Rollup}, "^(.+?),")

Hi Zack,
Thank you for your prompt response.

Works great for all fields except where I only have one email and then I get an error message. Is there a way to fix this?

Move the question mark to after the comma ^(.+),?

REGEX_EXTRACT({Email Rollup}, "^(.+),?")

Thank you; however, that returned all of the multiples. To be clear, I used the second formula and the error message was removed but the extraction of only one email part of the formula gave me multiple emails again. Basically, the second formula with the question mark moved after the comma gave me my exactly what my rollup gave me.

Sorry, I thought that was working for me.

The below does work for me in Airtable.

Try this [^,]*

Brilliant. I am doing the happy dance. Thank you. Those REGEX thingies are like martian speak to me.
:kiss:.

For anyone looking over our shoulders, this was the final formula: REGEX_EXTRACT({One email}, “[^,]*”)

Where, {One email} was my reference field.

1 Like

They are very new to me as well but are great with some basic understanding :+1:

Thanks to @Ben.Young. Thought they were scary and never attempted learning them before.

1 Like

As a bit of a side note, you can actually just write the whole formula inside of the rollup field’s formula configuration.

I’m on mobile right now, so this might look weird or need a tweak, but it would look something like this:

IF(
    values,
    REGEX_EXTRACT(
        values,
        '[^,]*'
    )
)

Thank you! That just eliminated a few extra fields! :partying_face:

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.