tuple_substrtuple_substrTupleSubstrTupleSubstrtuple_substr (Operator)
Name
tuple_substrtuple_substrTupleSubstrTupleSubstrtuple_substr
— Cut characters from position “n1” through “n2” out of a string tuple.
Signature
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_substrTupleSubstrTupleSubstrTupleSubstrtuple_substr
cuts all characters from position “n1” through “n2”
out of each string of the input tuple StringStringStringStringstringValstring
and
returns them as new strings in the output tuple SubstringSubstringSubstringSubstringsubstringsubstring
. The
positions “n1” and “n2” are determined by the second and third input
tuples Position1Position1Position1Position1position1position_1
and Position2Position2Position2Position2position2position_2
. Their
length has to be equal. If Position1Position1Position1Position1position1position_1
and Position2Position2Position2Position2position2position_2
only
contain one element, this element defines for all strings of
StringStringStringStringstringValstring
“n1” and “n2”, respectively . If
StringStringStringStringstringValstring
, Position1Position1Position1Position1position1position_1
and Position2Position2Position2Position2position2position_2
have got the
same number of elements, the first elements of Position1Position1Position1Position1position1position_1
and
Position2Position2Position2Position2position2position_2
determine the start and end position for the
first string of StringStringStringStringstringValstring
. The second elements of Position1Position1Position1Position1position1position_1
and Position2Position2Position2Position2position2position_2
do so for the second string of StringStringStringStringstringValstring
and so on. If Position1Position1Position1Position1position1position_1
and Position2Position2Position2Position2position2position_2
contain more than one element and StringStringStringStringstringValstring
contains only one string,
tuple_substrtuple_substrTupleSubstrTupleSubstrTupleSubstrtuple_substr
cuts more than one substring out of this string.
The elements of Position1Position1Position1Position1position1position_1
and Position2Position2Position2Position2position2position_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_substrTupleSubstrTupleSubstrTupleSubstrtuple_substr
returns an error.
If StringStringStringStringstringValstring
is an empty tuple, the operator returns an empty tuple.
If StringStringStringStringstringValstring
is not empty and Position1Position1Position1Position1position1position_1
and/or
Position2Position2Position2Position2position2position_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")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""filename_encoding" is set to 'locale'"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_substrTupleSubstrTupleSubstrTupleSubstrtuple_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
StringStringStringStringstringValstring
(input_control) string(-array) →
HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Input tuple with string(s) to examine.
Position1Position1Position1Position1position1position_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”.
Position2Position2Position2Position2position2position_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”.
SubstringSubstringSubstringSubstringsubstringsubstring
(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_nTupleStrFirstNTupleStrFirstNTupleStrFirstNtuple_str_first_n
,
tuple_str_last_ntuple_str_last_nTupleStrLastNTupleStrLastNTupleStrLastNtuple_str_last_n
,
tuple_strstrtuple_strstrTupleStrstrTupleStrstrTupleStrstrtuple_strstr
,
tuple_strrstrtuple_strrstrTupleStrrstrTupleStrrstrTupleStrrstrtuple_strrstr
,
tuple_strlentuple_strlenTupleStrlenTupleStrlenTupleStrlentuple_strlen
,
tuple_strchrtuple_strchrTupleStrchrTupleStrchrTupleStrchrtuple_strchr
,
tuple_strrchrtuple_strrchrTupleStrrchrTupleStrrchrTupleStrrchrtuple_strrchr
,
tuple_splittuple_splitTupleSplitTupleSplitTupleSplittuple_split
,
tuple_environmenttuple_environmentTupleEnvironmentTupleEnvironmentTupleEnvironmenttuple_environment
Module
Foundation