Skip to main content
Best answer

Extract name and amount from Google email using regex

  • October 26, 2023
  • 1 reply
  • 133 views

I am trying to extract text from gmail. I have a zap started with Email Parser. Then a step using Formatter to extract separate pieces. I can extract the email address and amount with success. I’m trying to extract a FirstName LastName pattern that always comes after an exclamation point and line breaks. I cannot get this to work. I can get different versions to work in Regex101.com using Python flavor. But when I put it in the zap it includes the text I want excluded.

I have no idea what I’m doing wrong. I am no expert in regex so please be kind. I’m sure there’s something very basic that I’m missing. Any help would be most appreciated. Thanks in advance!

 

Email text:
 

Hi name,

Congratulations!

FirstName LastName donated $10.00 to ….. 

 

Here’s the latest iteration of the regex I’ve been trying:

\W{2}(?P<name>.+?) donated\s(?P<amount>.+)\sto

What I want is

name: FirstName LastName

amount: $10.00

 

What I’m getting is:

name: Congratulations! FirstName LastName

amount: $10.00

 

I’ve also tried this which again, works elsewhere but not in my zap.

\b\s*(.+?)\s* donated

 

Best answer by Troy TessaloneBest answer by Troy Tessalone

Hi @lisa_nativegov 

Good question.

Have you tried asking ChatGPT for help with the RegEx.

 

Another option is to use this Zap action: ChatGPT - Extract Structured Data

 

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31067 replies
  • Answer
  • October 26, 2023

Hi @lisa_nativegov 

Good question.

Have you tried asking ChatGPT for help with the RegEx.

 

Another option is to use this Zap action: ChatGPT - Extract Structured Data