Best answer

Extract Data From Zendesk Ticket (email) using a start and end tag

  • 29 December 2021
  • 3 replies
  • 315 views

Userlevel 1

The end goal is to use a start and end tag to put around content dynamically entered by a user in a form and extract that to a field in Zendesk. 

 

The data coming into Zendesk will look like this:

 

Employee Name: !employee_name_start!John Smith Testing!employee_name_end!

 

The tags are hidden via html 0 size font but are around the dynamically entered content from the user (John Smith Testing). I want to look for the start tag and grab all data between it and the end tag. I have also tried the code below: 

 

import re

m = re.search('!employee_name_start!(.+?)!employee_name_end!', Description) if m: found = m.group(1)

 

My goal is that it will go through the description field (as shown in pic) and look for a starting tag of !employee_name_start! And an ending tag of !employee_name_end! And return whatever is in the middle (.+?) which would be the employees name in this case. My actual description field contains this in it:

icon

Best answer by GetUWired 30 December 2021, 17:37

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.

3 replies

Userlevel 7
Badge +14

Hi @BiometricBrady 

Try using Formatter > Text > Split in your Zap: https://zapier.com/help/create/format/get-started-with-formatter

OR you can use a Code step to do this parsing: https://zapier.com/apps/code/help

Userlevel 7
Badge +12

Hi @BiometricBrady 

Assuming you will have multiple start & end tags with different names, this could be done dynamically through a javascript code block and using regex. 

This solution uses the tag name to define the output key. 
 

 

 

let regex = /(?<=_start!).*(?=_end!)/g; //this will match anything between _start! and _end!


//match the description against the regex expression
let regexMatches = inputData.description.match(regex);
let matches = {};

//loop through matches splitting at remaining ! to get the key and values
for (var i=0;i<regexMatches.length;i++) {
var match_and_key = regexMatches[i].split("!");

var key = match_and_key[1];
var match = match_and_key[0];
matches[key] = match;
}
return matches


 

Userlevel 1

Hello,

 

Thank you so much! This worked for me and I am not building out all my flows to include the tags. Thanks again! 

 

Thanks,
Brady