Can't use Regex in IF to remove tracking part of an URL

Hey @miniduke,

The example below shows 3 ways you can extract the URL, The first Set node sets a variable with your Engadget URL then we call 3 other nodes…

The Function Item node adds a new variable called cleaned which contains just the URL

The Set Node sets a variable called Cleaned using the same regex option.

and the HTTP request is there to get the page using the same regex option so you can see how you could use it in a normal node.

The actual magic is performed by adding .match(/^[^?]+/) to the end of the input variable, I think where you were going wrong was you thought the If Node sets a variable which is not what an If node or an If statement in programming is for. You would use the If node to see if something matches a certain pattern it doesn’t do any clever extraction you would normally need to handle that after.

Workflow Example

Hopefully this helps and gets you on your way to automating your task :+1:

2 Likes