tuple_strchr
— Forward search for characters within a string tuple.
tuple_strchr
searches within the strings of the input tuple
String
for the characters of the input tuple ToFind
. Both
input tuples may only consist of strings. Otherwise tuple_strchr
returns an error. If the elements of ToFind
contain more than one
character, only the first character of each element is considered for
searching. If String
contains only one string, all the characters
defined in ToFind
are searched in this string. Thus, the output tuple
consists of as many elements as ToFind
. Whenever a searched
character has been found, the position of its first occurrence gets stored in
the output tuple Position
(remark: the position starts at 0 for the
first character of a string). If a character can not be found, -1 will be
returned instead of its position. If both input tuples show the same number
of elements, the search is done elementwise. I.e., the first character of
the first element of ToFind
is searched within the first string of
String
, the first character of the second element of ToFind
is searched within the second string of String
and so on. The
results of the elementwise searches are returned with Position
that
contains as many elements as String
and ToFind
. If
ToFind
only contains one string, its first character is searched
within all strings of String
. Thus, in this case Position
consists of as many elements as String
. If both input tuples
contain more than one element and the number of elements differs for the
input tuples, tuple_strchr
returns an error.
If either or both of the input tuples are empty, the operator returns an empty tuple.
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 provides an in-line operation for tuple_strchr
,
which can be used in an expression in the following syntax:
Position := strchr(String, ToFind)
String
(input_control) string(-array) →
(string)
Input tuple with string(s) to examine.
ToFind
(input_control) string(-array) →
(string)
Input tuple with character(s) to search.
Position
(output_control) integer(-array) →
(integer)
Position of searched character(s) within the string(s).
tuple_strrchr
,
tuple_strstr
,
tuple_strrstr
,
tuple_strlen
,
tuple_substr
,
tuple_str_first_n
,
tuple_str_last_n
,
tuple_split
,
tuple_environment
Foundation