Skip to main content

My trigger action provides Zapier with a few simple lists of data, but sometimes entries in these lists are blank. I use a formatter step to combine a few of these lists into one string of text. When I use this string in later steps, I often end up with a few instances of “comma space” or “, “ repeating next to each other, from blank entries in the previous lists.

Here’s an example of a string of text I will end up with after my Formatter step:
“Customizations: , , , , , , , Screen printing, 289+ pieces, Full Front , Other Small little logo on bottom of left side”

What’s the easiest way (read: fewest steps) to strip these useless blank “comma space” repeaters from this string? 

I know I can do Find>Replace as a Formatter step, but I’ll have to do one step for find “, , “ replace with “ “, then another step for find “, , , “ replace with “ “, etc. I tried using a Lookup Table to offer multiple strings to replaced in one step, but couldn’t get that to work properly.

Any suggestions are appreciated! 

Hi @IdleWilde Printing 

A code step can be used with RegEx to find/replace all instances of repeating commas.

Code: https://zapier.com/apps/code/help

replace(): https://www.w3schools.com/jsref/jsref_replace.asp

 

 

Give this JavaScript code a try...

let INPUT = inputData.INPUT;

let OUTPUT = INPUT.replace(/ ,/g,',').replace(/,,/g,'').replace(/:,/g,':').trim();

output = t{INPUT, OUTPUT}];

 


Hi @IdleWilde Printing 

A code step can be used with RegEx to find/replace all instances of repeating commas.

Code: https://zapier.com/apps/code/help

 

 

Thanks for the quick response and the suggestion, Troy. Trying to figure this out now.

I’m getting some errors from Zapier which I think is solely based on formatting/my lack of Javascript knowledge. I’m sure it’s a simple formatting issue I’m overlooking, can anyone help? I thought “lists” would be defined in the first part of mapping it to a data set, however I keep getting errors that it is undefined?


Sorry, looks like you added more info to your post since I started quoting. I think I have enough info now to figure this out. Thanks for your help.