Replaceall Issue

Hi all,

I am trying to replace a string within the Edit Fields node with another string.
Issue is that it doesn’t seem to replace the original string with the new string…
The Json is below any ideas what simple thing I am doing wrong :slight_smile:

{{ $json["Location"].replaceAll('EUROMASTERGBA161 BRIGHTON WEST (EX PORTSLADE)-8M','A161 BRIGHTON WEST (EX PORTSLADE)') }}

Many Thanks

Alex

Information on your n8n setup

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

hello @villa1980

can you provide the content of the original string from the $json["Location"] ?

The most obvious issue is that it has newlines or tabs, which you won’t be able to see in JSON or Schema views

Hi barn4k,

If I understand you correctly, the string I want to replace is EUROMASTERGBA161 BRIGHTON WEST (EX PORTSLADE)-8M
I want to replace it with
A161 BRIGHTON WEST (EX PORTSLADE)

I mean what was the original string (the one, in which you are trying to replace part of it, not the replacement part itself)? If it has only the content that you have specified, then you don’t need the replace function.

The function targetString.replaceAll("replace me", "replaced content") will replace all occurrences of the substring replace me with the new one replaced content in the string targetString.

E.g. if the targetString is:

some text with *replace me* words that you may see twice
*replace me* on the other line too

then it will be changed to

some text with *replaced content* words that you may see twice
*replaced content* on the other line too
1 Like

Thank-you for the reply, I thought it was something stupid I was doing.
Instead of double quotes I was inserting single quotes and then not giving the manual mapping a name of the column.

All sorted now, thank-you for your help.

1 Like

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