I have a form that is returning a string of visitors names. Returned string looks like this:
[{"First Name":"JAMES","Last Name":"SMITH"},{"First Name":"SARAH","Last Name":"SMITH"}]
I’m using JavaScript in Zapier to remove the special characters from the string:
let INPUT = inputData.INPUT;
let OUTPUT = INPUT.replace(/[^a-z0-9]/gi, '');
output = [{INPUT, OUTPUT}];
but that gives me this output:
FirstNameJAMESLastNameSMITHFirstNameSARAHLastNameSMITH
My ultimate goal is to produce something like this:
JAMES SMITH
SARAH SMITH
etc
Is it possible to remove the special characters EXCEPT for the string },{
? I could then use zapier to split the records using },{
as the identifier.
Thanks!
2
Answers
I am not terribly familiar with Zapier, but assuming it has basic JavaScript functionality I would be inclined to convert the string to an object and work from there rather than parse it myself or use regular expressions. You can do:
Which will give you an object instead of a string. Much easier to work with, and you can loop through it to perform any operations you need to on each visitor:
If you only need a string of visitor names separated by a space and don’t need to perform any actions on individual visitors, you can do:
As pointed out by Unmitigated
How are you?
Here is the code snippet, I just made, according to you requirement.
I hope this code works for you.
Thank you.