Replacing several strings in in one sentence

Describe the issue/error/question

Hi,
I am wondering if there is a better and cleaner way to replace several strings in a sentence at once? The way I do now is adding a replace line of code per each string I want to replace, but I am bit concerned with too many requests it will become very slow.

Looking for ideas to make it leaner and cleaner. Thank you very much in advance.

Please share the workflow

In theory you could use sed with an Execute Command node:

echo "{{$json["orig_string"]}}" | sed 's/pizza/pringles/g; s/coke/pepsi/g'

This might get a little unruly with multiple strings but will certainly be faster and lighter

3 Likes

Hey @Jorge_M,

You could replace several values with one value at once but replacing several values with different values would need something like you have.

2 Likes

Hey @joeldeteves, this worked perfect, thank you very much.

2 Likes

You’re welcome! Glad I could be of help!

1 Like

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