Skip to main content
Version: 8.1

split

This function is used by Ignition's Expression language.

Description

This function takes the string string and splits it into a bunch of substrings. The substrings are return as a dataset with one column called "parts". The split occurs wherever the regular expression regex occurs.

The optional limit argument, if greater than zero, limits the number of times the regex pattern is applied to limit-1. Put another way, it limits the length of the resulting dataset to length limit. If limit is non-positive then the regex pattern will be applied as many times as possible and the returned dataset can have any length. If limit is zero (the default) then the pattern will be applied as many times as possible, the returned dataset can have any length, and trailing empty strings will be discarded.

Syntax

split(string, regex, [limit])

  • Parameters

    • String string - The starting string.

    • String regex - The string to split on.

    • Integer limit - Optional. The max number of splits to make. Default 0 which is as many as possible.

  • Results

    • Dataset - The split string, with a single column called parts, where each row is a new part of the string.

Examples

Code Snippet
split("hello,world", ",") //returns dataset ["hello", "world"]
Code Snippet
split("boo:and:foo", ":") //returns dataset ["boo", "and", "foo"]
Code Snippet
split("boo:and:foo", ":", 2) //returns dataset ["boo", "and:foo"]