Skip to main content
Question

How to recover a text placed between certain words?

  • August 8, 2023
  • 2 replies
  • 33 views

Marion DEFONTAINE
Hello everyone,I want to create a zap allowing me to retrieve the first and last name appearing in the body of an email.I can't figure out why.Here is the body of the email in question:Raw Snippet Interested buyer ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ Interested buyer | Email not displaying correctly? Click here. Octavia Sobczyk is interested in this property €1,160,000 ARCANGUES, 64200I would like to retrieve the first and last name between "click here." and "is interested in this property".Here is the tested code:const bodyText = inputData['1. raw snippet'];const startText = "Click here.";const endText = "interested";const startIndex = bodyText.indexOf(startText) + startText.length;const endIndex = bodyText.indexOf(endText);if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {  const extractedText = bodyText.substring(startIndex, endIndex).trim();    output = {    extractedText: extractedText  };} else {  output = {    extractedText: "Extraction Failed"  };}

 

Thank for your helping.

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

GetUWired
Forum|alt.badge.img+12
  • Zapier Solution Partner
  • August 8, 2023

Hi @Marion DEFONTAINE,

Try changing the following:

bodyText = inputData.keyValue;   //where keyValue is the key for your text

endText = “is interested”;

 

Hope this helps!


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • August 8, 2023

Hi @Marion DEFONTAINE 

You can try asking ChatGPT to help with your code.

You can also try this Zap action: ChatGPT - Extract Structured Data