### 5.2.6 Splitting strings into lists of tokens

The split command splits a string into a sequence of substrings with respect to a given separator.

See Section 9.1.9 for other uses of split.

- split takes two arguments:
  - str, a string.
  - sep, a string specifying the separator.
- split(str,sep) returns a list of substrings [s1,s2,…,sn] of str such that s1+sep+s2+sep+..+sn returns str.
- To trim the returned substrings, you can enter the command apply(trim,res) provided that res holds the return value of split (see Section 5.2.5).

#### Examples

split("this is a phrase"," ")

| ⎡ ⎣ | “this”,“is”,“a”,“phrase” | ⎤ ⎦

apply(expr,split("112--34--567--89","--"))

| ⎡ ⎣ | 112,34,567,89 | ⎤ ⎦