Hello,
I have spent way too much time on this so asking the community for help.
The Data
The user is filling out a questionnaire. After some transformation the data arrives as follows from a set node
:
[
{
"data": {
"q18_whatsYour18": "Male",
"q17_challenges": [
"a1|https://www.jotform.com/uploads/asdf/form_files/a1-128x128-2248472.60d3cab956c375.09943307.png",
"a2|https://www.jotform.com/uploads/asdf/form_files/a2-128x128-2248466.60d3caca4e2559.33152533.png",
"a3|https://www.jotform.com/uploads/asdf/form_files/a3-128x128-2248449.60d3cae219eac1.79775248.png",
"a4|https://www.jotform.com/uploads/asdf/form_files/a4-128x128-2248486.60d3cbd359c942.09434264.png",
"a5|https://www.jotform.com/uploads/asdf/form_files/a5-128x128-2248475.60d3cbf8248e63.14540291.png",
"a6|https://www.jotform.com/uploads/asdf/form_files/a6-128x128-2248434.60d3cb25e31b08.05201007.png",
"a7|https://www.jotform.com/uploads/asdf/form_files/a7-128x128-2248451.60d3cb8a2a7b29.62396082.png",
"a8|https://www.jotform.com/uploads/asdf/form_files/a8-128x128-2248474.60d3cb5900e4c4.95872547.png"
]
}
]
The Goal
In a function node
I like to apply some regex to items[0].json.data
to achieve the following:
[
{
"data": {
"q18_whatsYour18": "Male",
"q17_challenges": [
"a1",
"a2",
"a3",
"a4",
"a5",
"a6",
"a7",
"a8"
]
}
]
The Regex
Here is what I tried
const regex = /(\|.+)"/gm;
works from regex https://regex101.com/
const subst = ``;
is what I want
So we could do a for in loop
here, but I can not get it to work.
Help would be much appreciated.
Thank you very much.
Chris