Best answer

Regex to find data in an email


I am trying to extract the text (shown in bold) after the colon ": " like the below but I am struggling to work out the expression I need to do so I can use that data later in a zap

 

Email: text

First Name: text

Last Name: text

Phone Number: text

Reason: text

Site: text

Town: text

PostCode: text

Country Code: text

Country Name: text

Help is much appreciated!

icon

Best answer by Danvers 5 May 2022, 15:15

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +14

Hi @thebot 

Good question.

That is known as email parsing.

Try using an email parser app such as Mailparser: https://zapier.com/apps/mailparser/integrations#triggers-and-actions

Userlevel 7
Badge +12

Hi @thebot!

There are a couple of ways that you could do this that would be easier than using regex. 

The first would be to use an email parser. You can use a dedicated app like MailParser, but if the format of the emails is relatively simple (eg the text you want will always be on a different line and in the same order) then you could try Email Parser by Zapier. Using an email parser, you forward relevant emails to your parser inbox and the it will pull out the relevant details based on a template that you set up in advance. This help guide explains how to set up an Email Parser by Zapier inbox and parser template. This would be the solution I’d choose in this situation. 

 

An alternative would be to use the Formatter by Zapier app, which you can use to split text based on things like a line break or semicolon. The main drawback of this approach is that you would end up using a LOT of steps in your Zap, so I wouldn’t generally recommend it. 

 

If neither of those work for you, let us know and hopefully someone in the Community can help you with the regex formula that you’d need 😀