Manipulate String n8n #571
Closed
hasanbasri1993
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi! It's more n8n related question, not the project. // Accessing input data (adjust this part if your structure is different)
const payload = $input.item.json;
// Check if the body field exists and is a string
if (payload.body && typeof payload.body === 'string') {
// Replacing all occurrences of "CHANNEL_" with an empty string
const modifiedBody = payload.body.replace(/CHANNEL_/g, "");
// Return the modified body
return [{ json: { body: modifiedBody } }];
} else {
throw new Error('The input body is not a string or does not exist');
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i'm triying to use n8n and i set the trigger
when the body is contain CHANNEL_
then send back agai but i nneed replace CHANNEL_
i try like this bu nothing happen using Code Block
return $input.payload.body.replace("CHANNEL_", "");
Thanks u
Beta Was this translation helpful? Give feedback.
All reactions