hugo2
October 17, 2023, 9:42am
1
Hello again guys,
Want to split a text from an array. It can be like that random :
{item1} / {item2}
{item1} and {item2}
{item1} , {item2}
I do that
But sometimes, split doesn’t work. the response remains similar to the input.
Formule is correct ? Or perhaps I should add each possible separator: “,” “/” or “and” in a separate module.
Regards,
samliew
October 17, 2023, 10:02am
2
You’ll need to use a “Match Pattern” module if you want multiple delimiters.
^(?<item1>.+)\s*(?:/|,|and)\s*(?<item2>.+)$
Output:
2 Likes
hugo2:
mhhhI have that
No, based on your first screenshot, you did not paste my pattern exactly . There is a duplicate end bit causing it to fail.
Plus, you should be selecting No for Global match.
2 Likes
hugo2
October 17, 2023, 3:08pm
5
Yes, because there can be more than one value, so I’ve adapted it like this :
^(?<item1>.+)\s*(?:/|,|and)\s*(?<item2>.+)\s*(?:/|,|and)\s*(?<item3>.+)\s*(?:/|,|and)\s*(?<item4>.+)\s*(?:/|,|and)\s*(?<item5>.+)\s*(?:/|,|and)\s*(?<item6>.+)$
Hi @hugo2 ,
I’d recommend you test your regular expressions before trying to use them in Make.
Use a site like regex101.com and select ECMAScript/JavaScript on the left side.
This site will also help you identify invalid patterns.
4 Likes
The pattern works exactly for the example you previously provided. You should be providing all the possible examples.
3 Likes