tuple_split
— Split strings into substrings using predefined separator symbol(s).
tuple_split( : : String, Separator : Substrings)
tuple_split
searches within the strings of the input tuple
String
for one or more separators defined in the input tuple
Separator
. tuple_split
then splits the examined strings into
the substrings divided by the separators. Both input tuples may only consist of
strings. Otherwise tuple_split
returns an error. If the elements of
Separator
contain more than one character, each character defines a
separator. If String
consists only of one string, this is split up
several times according to the elements of Separator
. For example:
If String
consists of the string “data1;data2:7;data3” and
Separator
contains the strings “;” and “:;”, the output tuple
Substrings
will comprise the strings “data1”, “data2:7”,
“data3” as the result of splitting the string of String
according
to the first element of Separator
and “data1”, “data2”, “7”
and “data3” as the result of splitting according to the second element of
Separator
. If both input tuples show the same number of elements,
the search is done elementwise. I.e., tuple_split
will split the
first string of String
according to the separators in the first
element of Separator
, the second string of String
according
to the separators in the second element of Separator
and so on. If
Separator
only contains one string, the separators defined in this
string will be used to split up all the strings of String
. If both
input tuples contain more than one element and the number of elements differs
for the input tuples, tuple_split
returns an error.
Subsequent occurences of Separator
in String
are
treated as one separator. Separators at the beginning and the end of
String
are ignored.
If either or both of the input tuples are empty, the operator returns an empty tuple.
The split characters are interpreted as Unicode code points. One Unicode
code point may be composed of multiple bytes in the UTF-8 string.
If the split characters should be handled as raw bytes of the string, this
operator can be switched to byte mode with
set_system('tsp_tuple_string_operator_mode', 'byte')
.
If 'filename_encoding' is set to 'locale' (legacy), this
operator always uses the byte mode.
For general information about string operations see Tuple / String Operations.
HDevelop provides an in-line operation for tuple_split
,
which can be used in an expression in the following syntax:
Substrings := split(String, Separator)
String
(input_control) string(-array) →
(string)
Input tuple with string(s) to split.
Separator
(input_control) string(-array) →
(string)
Input tuple with separator symbol(s).
Substrings
(output_control) string(-array) →
(string)
Substrings after splitting the input strings.
tuple_strstr
,
tuple_strrstr
,
tuple_strchr
,
tuple_strrchr
,
tuple_strlen
,
tuple_str_first_n
,
tuple_str_last_n
,
tuple_environment
Foundation