Operator Reference

tuple_substrtuple_substrTupleSubstrTupleSubstrtuple_substr (Operator)

tuple_substrtuple_substrTupleSubstrTupleSubstrtuple_substr — Cut characters from position “n1” through “n2” out of a string tuple.

Signature

tuple_substr( : : String, Position1, Position2 : Substring)

Herror tuple_substr(const char* String, const Hlong Position1, const Hlong Position2, char* Substring)

Herror T_tuple_substr(const Htuple String, const Htuple Position1, const Htuple Position2, Htuple* Substring)

void TupleSubstr(const HTuple& String, const HTuple& Position1, const HTuple& Position2, HTuple* Substring)

HTuple HTuple::TupleSubstr(const HTuple& Position1, const HTuple& Position2) const

def tuple_substr(string: MaybeSequence[str], position_1: MaybeSequence[Union[float, int]], position_2: MaybeSequence[Union[float, int]]) -> Sequence[str]

def tuple_substr_s(string: MaybeSequence[str], position_1: MaybeSequence[Union[float, int]], position_2: MaybeSequence[Union[float, int]]) -> str

Description

tuple_substrtuple_substrTupleSubstrTupleSubstrtuple_substr cuts all characters from position “n1” through “n2” out of each string of the input tuple StringStringStringstringValstring and returns them as new strings in the output tuple SubstringSubstringSubstringsubstringsubstring. The positions “n1” and “n2” are determined by the second and third input tuples Position1Position1Position1position1position_1 and Position2Position2Position2position2position_2. Their length has to be equal. If Position1Position1Position1position1position_1 and Position2Position2Position2position2position_2 only contain one element, this element defines for all strings of StringStringStringstringValstring “n1” and “n2”, respectively . If StringStringStringstringValstring, Position1Position1Position1position1position_1 and Position2Position2Position2position2position_2 have got the same number of elements, the first elements of Position1Position1Position1position1position_1 and Position2Position2Position2position2position_2 determine the start and end position for the first string of StringStringStringstringValstring. The second elements of Position1Position1Position1position1position_1 and Position2Position2Position2position2position_2 do so for the second string of StringStringStringstringValstring and so on. If Position1Position1Position1position1position_1 and Position2Position2Position2position2position_2 contain more than one element and StringStringStringstringValstring contains only one string, tuple_substrtuple_substrTupleSubstrTupleSubstrtuple_substr cuts more than one substring out of this string. The elements of Position1Position1Position1position1position_1 and Position2Position2Position2position2position_2 then determine the start and end positions for these substrings. If all input tuples contain more than one element but differ in the number of elements, tuple_substrtuple_substrTupleSubstrTupleSubstrtuple_substr returns an error.

If StringStringStringstringValstring is an empty tuple, the operator returns an empty tuple. If StringStringStringstringValstring is not empty and Position1Position1Position1position1position_1 and/or Position2Position2Position2position2position_2 are empty tuples, an exception is raised.

Unicode code points versus bytes

The positions reference Unicode code points. One Unicode code point may be composed of multiple bytes in the UTF-8 string. If the positions should reference the 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")set_system("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_substrtuple_substrTupleSubstrTupleSubstrtuple_substr, which can be used in an expression in the following syntax:

Substring := String{Position1:Position2}

Execution Information

  • Multithreading type: independent (runs in parallel even with exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Processed without parallelization.

Parameters

StringStringStringstringValstring (input_control)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Input tuple with string(s) to examine.

Position1Position1Position1position1position_1 (input_control)  number(-array) HTupleMaybeSequence[Union[float, int]]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Input tuple with start position(s) “n1”.

Position2Position2Position2position2position_2 (input_control)  number(-array) HTupleMaybeSequence[Union[float, int]]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Input tuple with end position(s) “n2”.

SubstringSubstringSubstringsubstringsubstring (output_control)  string(-array) HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Characters of the string(s) from position “n1” to “n2”.

Alternatives

tuple_str_first_ntuple_str_first_nTupleStrFirstNTupleStrFirstNtuple_str_first_n, tuple_str_last_ntuple_str_last_nTupleStrLastNTupleStrLastNtuple_str_last_n, tuple_strstrtuple_strstrTupleStrstrTupleStrstrtuple_strstr, tuple_strrstrtuple_strrstrTupleStrrstrTupleStrrstrtuple_strrstr, tuple_strlentuple_strlenTupleStrlenTupleStrlentuple_strlen, tuple_strchrtuple_strchrTupleStrchrTupleStrchrtuple_strchr, tuple_strrchrtuple_strrchrTupleStrrchrTupleStrrchrtuple_strrchr, tuple_splittuple_splitTupleSplitTupleSplittuple_split, tuple_environmenttuple_environmentTupleEnvironmentTupleEnvironmenttuple_environment

Module

Foundation