Slice Text with JavaScript Code

  • 9 March 2022
  • 0 replies
Slice Text with JavaScript Code
Userlevel 7
Badge +14

📌  We do our best to ensure that the code in these articles works as advertised, but please be aware that Zapier Support does not officially help with code steps due to their advanced nature. Feel free to comment on the article or ask in the Zapier Community, where we have code-savvy users.

The Purpose

To manipulate text by slicing from the start and/or end.

How to Configure

Copy the Code

let Text = inputData.Text;
let Text1 = Text.slice(4); // slice off the first 6 characters (0-5)
let Text2 = Text.slice(-6); // slice off the last 6 characters
let Text3 = Text.slice(0,5); // slice only the first 6 characters (0-5)
let Text4 = Text.slice(3,-4); // slice from after first 4 characters (0-3) and before the last 4 characters

// NOTE: First character position starts at 0

output = [{Text, Text1, Text2, Text3, Text4}];

The Results

Contribution by Troy Tessalone

Troy is a Certified Zapier Expert who automates workflows with no-code and low-code apps to help clients save time and make money.

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.