> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.itential.com/itential-platform/2023-2/studio/tasks/reference/slice-string/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server. # slice (string) > Reference for the slice (string) workflow task, which extracts part of a string between specified start and end indexes. ## Task purpose 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. ## Potential use case 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. ## Properties | Incoming | Type | Description | | ------------ | ------ | ---------------------------------------------------------------------------------------------------------------- | | `str` | String | Required. The string containing the value to extract. | | `beginIndex` | Number | Required. The position at which to begin extraction. The first character is at position `0`. Defaults to `0`. | | `endIndex` | Number | Optional. The position at which to stop extraction. Extraction proceeds up to, but not including, this position. | If `endIndex` is less than `beginIndex`, `slicedString` returns an empty string (`""`). If this is not the desired behavior, consider using the `substring` task instead. | Outgoing | Type | Description | | -------------- | ------ | --------------------------------------------------------- | | `slicedString` | String | The portion of `str` between `beginIndex` and `endIndex`. | ## Examples ### Example 1 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"`). * Because `beginIndex` is greater than `endIndex`, `slicedString` returns `""` (an empty string). ![](/_fern-img/f5d2a1d09c9da1428c2d9b546652722ee4a344beadcdf05af7b4706ea87e0d86.webp)![](/_fern-img/530e5fd2dfcc8395ae1cc902f30b2493ef3c076011f1cceb2a9388d6f02cc94c.webp)![](/_fern-img/ff3b2db4501845804088007d93d7da1658fec7937dba0ba58e0cd3ab7fbf4900.webp) ### Example 2 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`. ![](/_fern-img/3f72e297093e5b6dfd9e9dc754c80d22d008c8ac56ace93e867eba5b06d69e60.webp)![](/_fern-img/8fb553565dab84d7f8ff7eed1f2d15d297c1e406a7b60edfa111f229749d025e.webp)![](/_fern-img/2d3a3b0c7dd66e95ef1bb2bdc2f22562bf8f0f35a22ad9d174a397a89900f2ce.webp) ## Related reading * [slice (string) API reference](https://apidocs.itential.com/api/app-workflow_engine/stringSlice/) > Reference for the slice (string) workflow task, which extracts part of a string between specified start and end indexes.