Here’s how to use split() function.
Description:
Split a string into a sequence using the delimiter.
Syntax:
s.split(d)
Note:
The function splits string s with delimiter d to form a sequence and returns it.
Parameter:
s |
A string to be split |
d |
The delimiter; support splitting a string into multiple characters; if omitted, split the string into a sequence of single characters. |
Option:
@p |
Parse members into corresponding data types after the splitting. That is to say, numbers shall be handled as numeric values, members enclosed by [] shall be recognized as sequences, dates like 2001-01-01 shall be treated as date type data, and so on. The parsing of the sign [] also involves the same handling of a sub-sequence. Parentheses matching will be handled. |
@1 |
Split string into two parts by the first d found. |
@b |
Won’t handle quotation marks matching and parentheses matching. |
@t |
Perform trim operation to remove blank characters from both ends of each string member, and split the original string according to continuous blank characters when d is omitted. |
@c |
Split the string using the comma. |
@r |
Treat parameter d as a regular expression |
@n |
Spit a string using the carriage return \n, and split each substring according to the other options if there are any, and return a sequence of sequences |
Return value:
A sequence of strings
Example:
|
A |
|
1 |
="1,[a,b],(2,c),'5,6'" |
|
2 |
=A1.split@c() |
Comma is used to split the string |
3 |
=A1.split@c1() |
Split the string according to the first dilimiter |
4 |
=A1.split@cb() |
Use comma as the delimiter and won’t handle quotation marks matching and parentheses matching |
5 |
="a:b:c".split(":") |
Use colon as the dilimiter |
6 |
=A1.split@cp() |
Use comma as the delimiter and parse each split member into its proper data type |
7 |
="1,[a,b],(2,c), abc ,'5,6'".split@ct() |
Remove blank characters from both ends of "abc" |
8 |
="1,[a,b],(2,c), abc ,'5,6'".split@t() |
Split the string according to continuous blank characters since d is omitted |
9 |
=A1.split() |
Split the string into a sequence of single characters since d is omitted |
="a:;b:;c".split(":;") |
["a","b","c"] |
|
11 |
="a1b2c".split@r("(\\d)") |
|
12 |
="s,a,y\ngood,morning".split@nc() |
Split the string into [s,a,y] and [good,moring] and then split each substring by comma |