Skip to main content

Hello friends,

 

I try for a long time to use a Regex pattern to extract all characters from a sentence, except some special characters.

Here is an example of the original sentence data :

>"https:\/\/www.website.com\/sub_1\/sub_2\/sub_3\/sub_4\/sub_5\/sub_6\/File1.pdf","https:\/\/www.website.com\/sub_1\/sub_2\/sub_3\/sub_4\/sub_5\/sub_6\/File93.pdf","https:\/\/www.website.com\/sub_1\/sub_2\/sub_3\/sub_4\/sub_5\/sub_6\/File83.pdf","https:\/\/www.website.com\/sub_1\/sub_2\/sub_3\/sub_4\/sub_5\/sub_6\/File73.pdf","https:\/\/www.website.com\/sub_1\/sub_2\/sub_3\/sub_4\/sub_5\/sub_6\/File63.pdf","https:\/\/www.website.com\/sub_1\/sub_2\/sub_3\/sub_4\/sub_5\/sub_6\/File53.pdf","https:\/\/www.website.com\/sub_1\/sub_2\/sub_3\/sub_4\/sub_5\/sub_6\/File43.pdf"]

 

My goal is to remove the characters g ] \ andto keep only the url’s separeted by comma.

I can do it in 4 steps (1st remove e, 2nd remove ], … but my entire zap will have more than 50 steps at the end !

I tried this Python regex :

import re

regex = r"e^]x\"]"
 

But output is 0 😕

If anyone have an idea, it should be really friendly !

Brest Regards,

Thommen

Hi @Thommen 

Good question.

Try asking AI (ChatGPT) for help: https://chat.openai.com

ChatGPT can generate the JavaScript / Python code to use in a Code step.


@Troy Tessalone I’m on ChatGPT for that, just now 🙂 But it doesn’t work with the code generated, for the moment. I continue to try :-)


@Thommen 

Example with JavaScript

You will need to tweak a bit to work with the code formatting that a Zap Code step expects.

 

 


@Thommen 

 

CONFIG

 

CODE

let X = inputData.X;

let Y = X.replace(/e\/\]\\"]/g, '');

output = {X, Y}];

 

RESULTS

 


@Troy Tessalone Thank you a lot!