split()

Read(309) Label: string, delimiter, sequence,

Here’s how to use split() function.

s.split()

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.

Parameters:

s

A string to be splitted

d

The delimiter; support splitting a string into multiple characters; if omitted, split the string into a sequence of single characters.

Options:

@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

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

10

="a:;b:;c".split(":;")

["a","b","c"]

11

="a1b2c".split@r("(\\d)")