Skip to main content
Solved

Extracting first email in a field with multiple emails

  • August 28, 2022
  • 9 replies
  • 82 views

Kirsten_Kern
Forum|alt.badge.img+6

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?

Best answer by Kirsten_Kern

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:

9 replies

Zack_S
Forum|alt.badge.img+17
  • Inspiring
  • 95 replies
  • August 28, 2022

Hi @Kirsten_Kern,

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

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

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

Kirsten_Kern
Forum|alt.badge.img+6
  • Author
  • Inspiring
  • 7 replies
  • August 28, 2022

Hi @Kirsten_Kern,

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

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?


Zack_S
Forum|alt.badge.img+17
  • Inspiring
  • 95 replies
  • August 28, 2022

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}, "^(.+),?")

Kirsten_Kern
Forum|alt.badge.img+6
  • Author
  • Inspiring
  • 7 replies
  • August 28, 2022

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.


Zack_S
Forum|alt.badge.img+17
  • Inspiring
  • 95 replies
  • August 28, 2022

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 [^,]*


Kirsten_Kern
Forum|alt.badge.img+6
  • Author
  • Inspiring
  • 7 replies
  • August 28, 2022

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.


Zack_S
Forum|alt.badge.img+17
  • Inspiring
  • 95 replies
  • August 28, 2022

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.


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

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


Ben_Young1
Forum|alt.badge.img+22
  • Brainy
  • 520 replies
  • August 28, 2022

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

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


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,
        '[^,]*'
    )
)

Kirsten_Kern
Forum|alt.badge.img+6
  • Author
  • Inspiring
  • 7 replies
  • Answer
  • August 29, 2022

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: