tuple_splittuple_splitTupleSplitTupleSplit (Operator)

Name

tuple_splittuple_splitTupleSplitTupleSplit — Split strings into substrings using predefined separator symbol(s).

Signature

tuple_split( : : String, Separator : Substrings)

Herror tuple_split(const char* String, const char* Separator, char* Substrings)

Herror T_tuple_split(const Htuple String, const Htuple Separator, Htuple* Substrings)

void TupleSplit(const HTuple& String, const HTuple& Separator, HTuple* Substrings)

HTuple HTuple::TupleSplit(const HTuple& Separator) const

static void HOperatorSet.TupleSplit(HTuple stringVal, HTuple separator, out HTuple substrings)

HTuple HTuple.TupleSplit(HTuple separator)

Description

tuple_splittuple_splitTupleSplitTupleSplitTupleSplit searches within the strings of the input tuple StringStringStringStringstringVal for one or more separators defined in the input tuple SeparatorSeparatorSeparatorSeparatorseparator. tuple_splittuple_splitTupleSplitTupleSplitTupleSplit then splits the examined strings into the substrings divided by the separators. Both input tuples may only consist of strings. Otherwise tuple_splittuple_splitTupleSplitTupleSplitTupleSplit returns an error. If the elements of SeparatorSeparatorSeparatorSeparatorseparator contain more than one character, each character defines a separator. If StringStringStringStringstringVal consists only of one string, this is split up several times according to the elements of SeparatorSeparatorSeparatorSeparatorseparator. For example: If StringStringStringStringstringVal consists of the string “data1;data2:7;data3” and SeparatorSeparatorSeparatorSeparatorseparator contains the strings “;” and “:;”, the output tuple SubstringsSubstringsSubstringsSubstringssubstrings will comprise the strings “data1”, “data2:7”, “data3” as the result of splitting the string of StringStringStringStringstringVal according to the first element of SeparatorSeparatorSeparatorSeparatorseparator and “data1”, “data2”, “7” and “data3” as the result of splitting according to the second element of SeparatorSeparatorSeparatorSeparatorseparator. If both input tuples show the same number of elements, the search is done elementwise. I.e., tuple_splittuple_splitTupleSplitTupleSplitTupleSplit will split the first string of StringStringStringStringstringVal according to the separators in the first element of SeparatorSeparatorSeparatorSeparatorseparator, the second string of StringStringStringStringstringVal according to the separators in the second element of SeparatorSeparatorSeparatorSeparatorseparator and so on. If SeparatorSeparatorSeparatorSeparatorseparator only contains one string, the separators defined in this string will be used to split up all the strings of StringStringStringStringstringVal. If both input tuples contain more than one element and the number of elements differs for the input tuples, tuple_splittuple_splitTupleSplitTupleSplitTupleSplit returns an error. Subsequent occurences of SeparatorSeparatorSeparatorSeparatorseparator in StringStringStringStringstringVal are treated as one separator. Separators at the beginning and the end of StringStringStringStringstringVal are ignored.

If either or both of the input tuples are empty, the operator returns an empty tuple.

Unicode code points versus bytes

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')set_system("tsp_tuple_string_operator_mode", "byte")SetSystem("tsp_tuple_string_operator_mode", "byte")SetSystem("tsp_tuple_string_operator_mode", "byte")SetSystem("tsp_tuple_string_operator_mode", "byte"). If 'filename_encoding'"filename_encoding""filename_encoding""filename_encoding""filename_encoding" is set to 'locale'"locale""locale""locale""locale" (legacy), this operator always uses the byte mode.

For general information about string operations see Tuple / String Operations.

HDevelop In-line Operation

HDevelop provides an in-line operation for tuple_splittuple_splitTupleSplitTupleSplitTupleSplit, which can be used in an expression in the following syntax:

Substrings := split(String, Separator)

Execution Information

Parameters

StringStringStringStringstringVal (input_control)  string(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Input tuple with string(s) to split.

SeparatorSeparatorSeparatorSeparatorseparator (input_control)  string(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Input tuple with separator symbol(s).

SubstringsSubstringsSubstringsSubstringssubstrings (output_control)  string(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Substrings after splitting the input strings.

Alternatives

tuple_strstrtuple_strstrTupleStrstrTupleStrstrTupleStrstr, tuple_strrstrtuple_strrstrTupleStrrstrTupleStrrstrTupleStrrstr, tuple_strchrtuple_strchrTupleStrchrTupleStrchrTupleStrchr, tuple_strrchrtuple_strrchrTupleStrrchrTupleStrrchrTupleStrrchr, tuple_strlentuple_strlenTupleStrlenTupleStrlenTupleStrlen, tuple_str_first_ntuple_str_first_nTupleStrFirstNTupleStrFirstNTupleStrFirstN, tuple_str_last_ntuple_str_last_nTupleStrLastNTupleStrLastNTupleStrLastN, tuple_environmenttuple_environmentTupleEnvironmentTupleEnvironmentTupleEnvironment

Module

Foundation