- 21 Jun 2022
- Updated on 21 Jun 2022
split Task Purpose
The split task is used to split a string into an array of substrings using a given separator or point where the split should take place. Once the split is executed, the result is a new array containing the split values. The original string is not changed.
Potential Use Case
A comma separated list of ticket numbers is provided to the automation. Using the split task, you are able to create an array of the ticket numbers for subsequent processing in the workflow.
Input and output parameters are shown below.
||String||Required. The string to split.|
||String||Specifies the point where each split should occur. The separator can be a single character or multiple characters. If the separator is omitted then the entire string becomes one single array element. If the separator is an empty string (“”) then every character of the string is separated.|
||Number||Specifies the number of splits in a given string; items after the split limit are not included in the returned array. The limit parameter can be zero or a non-negative integer.|
||Array||An array of strings formed after splitting the given string at each point where the separator occurs.|
In the IAP example shown below:
strvariable is required.
The variables are set prior to running the workflow. In the example below, the string is "Hello World". The letter "o" is the separator and the limit is set to "3".
Once the workflow is executed, you can view the output in Task History, which is accessed from Jobs in Operations Manager. In the example, three (3) splits were made to the original input string, at each instance of the letter "o". Of note,
splitalso looks for and includes white-space.