| Operator Type: | Function |
| Operator Scope of Action: | Item |
| Operator Purpose: | Data manipulation |
String.split("pattern")
New to v5.7.1, this operator splits a string into a list, as divided by instances of pattern in the original string. Source characters forming part of pattern are not passed to the list. The source string itself is not affected.
pattern is one of:
- an action code expression (which includes just referencing a single attribute name')
- a quoted string; quoted strings may be either:
- a literal string (i.e. actual text)
- a regular expression
The result of the operator is a List-type attribute value, i.e. the data should be passed to a list. Passing the output to s Set-type attribute will de-dupe any list values in the output with the first instance of any duplicates forming its set entry.
For example:
$MyList = "ant bee ant cow".split(" ") gives "ant;bee;ant;cow"
$MySet = "ant bee ant cow".split(" ") gives "ant;bee;cow"
$MyList = "ant, bee, cow".split("\W+ ") gives "ant;bee;cow"
$MyList = "ant, bee, cow".split(" ") gives "ant,;bee,;cow"
$MyList = $MyString.split($MyString(agent))
$MyList = $MyString(parent).split("and")
Useful pattern values are "\W+" and "\.". The first splits the source at word boundaries removing spaces and punctuation. The second divides on sentences ending with a period - it will strip the terminating punctuation but not that within the sentence.
