Remove Quotation Marks from other Variable

Hi all,

I’m new to n8n (self-hosted on a server via Coolify) and making an effort to move away from make.com :-). However, I have an issue: I am scraping a website with ninja scraper and getting three variables as a result. One of which, I took care to clean up, so I can pass it on to OpenAI in a JSON:

{{ $(‘Scrape Site’).item.json.extractor.result.richTextClean }}

This variable contains quotation marks at the start and end of the text. That is a problem, because the JSON itself already contains quotation marks. And I can’t escape the quotation marks in the variable. Well, with two backslashes before {{ $(‘Scrape Site’).item.json.extractor.result.richTextClean }} I can escape the first one, but not the last. Does anyone have any ideas?

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Took care of itself. I asked chatGPT to add a backslash as a final character to the javascript in order to escape the quotation mark.

2 Likes

Awesome! That’s one way to do it :slight_smile:

For future, you could also utilize the built-in replace/replaceAll function together with some regex to help with string cleanups in your expressions.

image

I’ll avoid anything related to regex as long as I can, but it’s a cool idea. Thank you for that :pray:!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.