slice (string)
slice (string)
slice (string)
Similar to the substring task, the slice (string) task extracts part of a string and returns the extracted part in a new string. The part to extract is specified by start and end indexes, or extends to the end of the string if no end index is provided.
Use this task when you need to extract a specific portion of a string — for example, extracting only the telephone area code from an incoming phone number string.
If endIndex is less than beginIndex, slicedString returns an empty string (""). If this is not the desired behavior, consider using the substring task instead.
In this example:
str is statically set to 800-555-1212.beginIndex is 7 — extraction begins at the second dash.endIndex is 4 — extraction would stop before character 4 (the first "5").beginIndex is greater than endIndex, slicedString returns "" (an empty string).


In this example:
str is statically set to 800-555-1212.beginIndex is 4 — extraction begins at the first "5".endIndex is 7 — extraction stops before character 7 (the second "-").slicedString returns 555.

