The split Function breaks down your string into an array of strings using the delimiter that you defined. Think of the delimiter as a border. The left of the delimiter is an entry on the array, and the right is another. The function will validate all occurrences of the delimiter, not only the first, so your array will have an unknown number of entries.
It follows a simple pattern.
String 'I want to use the keyword with to split the text into 2' split('I want to use the keyword with to split the text into 2','with') will return [ "I want to use the keyword ", " to split the text into 2" ]
Quite straightforward, right?
It works in multiple languages. Let’s see an example in Thai:
String: 'สวัสดี' split('สวัสดี','วั') will return [ "ส", "สดี" ]
Sorry for my Thai readers if this doesn’t make sense. I searched for the word hello, picked a character to demonstrate the split function so that the final result may look strange.
It’s not a limitation, but you should be aware of it. The function removes the delimiter when doing the split. If you want to keep it, you have to add it by appending to the element of the string that makes sense.
- If the array returns only one row, it means that something’s wrong or your text doesn’t contain the delimiter. If you always expect the character and having multiple lines, I recommend checking if the array is greater than 1. You can use the length function to check:
length(<variable, compose, etc>)
- You can’t nest split functions unless you refer to the specific array element. Remember that the function requires a string and not an array. To nest, you have to do something like this:
split(split('Hello World','a'),'l') and you'll get: [ "He", "", "o Wor", "d" ]
- Based on the example above, I don’t recommend nesting because it can lead to issues. Let’s say that you have a string that doesn’t have any occurrence of the separator. You’ll get an array with one element. If you reference the second element of the array, you’ll have an invalid result and an error. If you have to do that, split, validate, and then split again.
- The function won’t remove the spaces if they are not part of the delimiter. It validates the string as-is, so if there’s a space before or after, your string will contain them. Be aware of this when parsing the elements of the array.
- If you have sequential entries of the delimiter or it shows up in the start or the end of the string, the function will still generate a new item in the array with an empty String. Please consider this while parsing the array. Think about the following example:
split('the delimiter is the','the') you'll get: [ "", " delimiter is ", "" ]
- The comparison is case sensitive so, if you want to get all occurrences of the delimiter, you have first to use the toUpper or toLower functions to be sure that you’re always comparing the same thing. For example:
split('The delimiter is the','the') you'll get: [ "The delimiter is ", "" ] So if you want to get all occurences of 'the' you should do something like: split(toLower('The delimiter is the'),'the') and you'll get: [ "", " delimiter is ", "" ]
Back to the Power Automate Function Reference.