Help regex function!

Describe the issue/error/question

Hi! im goingt crazy with what i thought was going to be aeasy thing. I have a string like this:

<>; rel="canonical"

I just wante to extract the URL , so i want the output to be:

I have no idea about javascript, but ive researced for formula’s and it seems REGEX should do it, however i keep running into different errors and have no idea why … i attach a screenshot of the last error i got … is it because ITEM isn’t a string and the REGEX function only works on strings?

What is the error message (if any)?

ERROR: Cannot convert undefined or null to object


Please share the workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm,, desktop app]:

Hi @oly-dev would this do the trick for you?

const url = items[0].json.url;

let start = url.indexOf("<");
let stop = url.indexOf(">");

let result = url.substring(start +1, stop);

return {"result": result}

continuing on answer by @dickhoning here an alternative with the Regex pattern.

const url = items[0].json.url;
let result = url.match(“^<([^>]*)”)[1];
return {“result”: result}

1 Like