Skip to content

tuple_substrTupleSubstrTupleSubstrtuple_substrtuple_substr🔗

Short description🔗

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

Signature🔗

tuple_substr( string String, number Position1, number Position2, out string Substring )void TupleSubstr( const HTuple& String, const HTuple& Position1, const HTuple& Position2, HTuple* Substring )static void HOperatorSet.TupleSubstr( HTuple stringVal, HTuple position1, HTuple position2, out HTuple substring )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]] ) -> strHerror 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 )

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

HTuple HTuple.TupleSubstr( HTuple position1, HTuple position2 )

Description🔗

tuple_substrTupleSubstr cuts all characters from position “n1” through “n2” out of each string of the input tuple StringstringValstring and returns them as new strings in the output tuple Substringsubstringsubstring. The positions “n1” and “n2” are determined by the second and third input tuples Position1position1position_1 and Position2position2position_2. Their length has to be equal. If Position1position1position_1 and Position2position2position_2 only contain one element, this element defines for all strings of StringstringValstring “n1” and “n2”, respectively . If StringstringValstring, Position1position1position_1 and Position2position2position_2 have got the same number of elements, the first elements of Position1position1position_1 and Position2position2position_2 determine the start and end position for the first string of StringstringValstring. The second elements of Position1position1position_1 and Position2position2position_2 do so for the second string of StringstringValstring and so on. If Position1position1position_1 and Position2position2position_2 contain more than one element and StringstringValstring contains only one string, tuple_substrTupleSubstr cuts more than one substring out of this string. The elements of Position1position1position_1 and Position2position2position_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_substrTupleSubstr returns an error.

If StringstringValstring is an empty tuple, the operator returns an empty tuple. If StringstringValstring is not empty and Position1position1position_1 and/or Position2position2position_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'). If 'filename_encoding'"filename_encoding" is set to '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_substrTupleSubstr, which can be used in an expression in the following syntax:

texttt{Substring := String{Position1:Position2}}

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

StringstringValstring (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Input tuple with string(s) to examine.

Position1position1position_1 (input_control) number(-array) → (integer / real)HTuple (Hlong / double)HTuple (int / long / double)MaybeSequence[Union[float, int]]Htuple (Hlong / double)

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

Position2position2position_2 (input_control) number(-array) → (integer / real)HTuple (Hlong / double)HTuple (int / long / double)MaybeSequence[Union[float, int]]Htuple (Hlong / double)

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

Substringsubstringsubstring (output_control) string(-array) → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

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

Combinations with other operators🔗

Combinations

Alternatives

tuple_str_first_nTupleStrFirstN, tuple_str_last_nTupleStrLastN, tuple_strstrTupleStrstr, tuple_strrstrTupleStrrstr, tuple_strlenTupleStrlen, tuple_strchrTupleStrchr, tuple_strrchrTupleStrrchr, tuple_splitTupleSplit, tuple_environmentTupleEnvironment

Module🔗

Foundation