tuple_str_first_nš
Short descriptionš
tuple_str_first_n ā Cut the first characters up to position ānā out of a string tuple.
Signatureš
tuple_str_first_n( string String, number Position, out string Substring )
Descriptionš
tuple_str_first_n cuts the first characters up to position ānā out
of each string of the input tuple String and returns them as new
strings in the output tuple Substring (remark: the position within
strings starts with 0 for the first character of a string). The number ānā
is determined by the second input tuple Position. If
Position only contains one element, this element contains the number
ānā. If String and Position have got the same number of
elements, the first element of Position determines the position
ānā for the first string of String, the second element of
Position does so for the second string of String and so on.
If Position contains more than one element and String
contains only one string, tuple_str_first_n cuts more than one
substrings out of this string. The elements of Position then
determine the lengths of these substrings. If both input tuples contain more
than one element but differ in the number of elements,
tuple_str_first_n returns an error.
If both input tuples are empty, the operator returns an empty tuple.
Similarly, if String is empty and Position is
not, the operator returns an empty tuple. In contrast, if Position
is empty and String is not, an exception is raised.
Unicode code points versus bytesš
The position references Unicode code points. One Unicode code point may be
composed of multiple bytes in the UTF-8 string. If the position 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' is set to '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_str_first_n,
which can be used in an expression in the following syntax:
Substring := str_firstn(String, Position)
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š
String (input_control) string(-array) ā (string)
Input tuple with string(s) to examine.
Position (input_control) number(-array) ā (integer / real)
Input tuple with position(s) ānā.
Substring (output_control) string(-array) ā (string)
The first characters of the string(s) up to position ānā.
Combinations with other operatorsš
Combinations
Alternatives
tuple_str_last_n, tuple_substr, tuple_strstr, tuple_strrstr, tuple_strlen, tuple_strchr, tuple_strrchr, tuple_split, tuple_environment
Moduleš
Foundation