Need Assistance with Regex for Parsing Email Text

I’m currently working on a project where I need to parse specific pieces of information from emails using regex, but I’ve encountered some challenges. I would greatly appreciate any guidance or insights you could provide.

Objective: I want to extract the following pieces of information from an email:

  1. Product Option (e.g., “eSIM USA 1GB 7Days”)
  2. Unique ID (e.g., “124874818726”)
  3. Main Customer’s Name (e.g., “Adam Jeo”)
  4. Customer’s Email Address (e.g., “customer-d6s7f6ds7678ds67@reply.getyourguide.com”)
    Email Sample:
Hi supply partner,

Great news! The following offer has been booked:

eSIM USA for Travelers: (USA-eSIM-EU01) 
Option: eSIM USA 1GB 7Days (124874818726)

View booking
Most important data for this booking:

Date: 03 February 2024

Price: € 13.77

Number of participants: 
1 x Adult (Age 0 - 99 ) (€ 13.77) 

Reference number: XXX8HDJ3

Main customer:
Adam Jeo

Romania
customer-d6s7f6ds7678ds67@reply.getyourguide.com
Phone: +4174356XXXX

Best regards,
The GetYourGuide Team

Attempted Regex Pattern:

I’ve tried constructing a regex pattern to capture these details, but it doesn’t seem to match the subject string as expected. Here’s my latest attempt:

Option:\s*(.+)\s*\((\d+)\).*Main customer:\s*(.*)\n\n.*(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b)

Specific Questions:

  1. Is there a more effective way to structure this regex to ensure it captures all the required information from the email text?
  2. Are there special considerations I should be aware of when using regex within Make.com, particularly regarding multi-line strings and non-greedy matching?

Any advice, sample patterns, or resources you could share would be immensely helpful. Thank you in advance for your time and assistance!

Hey @Adil

I just try to solve this by two approaches

Option: (\w+(?: \w+)*) ((\d+))

Main customer:\n(.+)

([a-zA-Z0-9._%±]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,})

3 Likes

Thank you so much for your help, can i use only 1 Text parser for all data? like 1 regex

Hey @Adil

I tried, but it is not working. You can use ChatGPT for better results; just use the proper prompt.