Best answer

Extract name and amount from Google email using regex

  • 26 October 2023
  • 1 reply
  • 68 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

 

icon

Best answer by Troy Tessalone 26 October 2023, 03:07

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.

1 reply

Userlevel 7
Badge +14

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