tuple_strstrtuple_strstrTupleStrstrTupleStrstrtuple_strstr (Operator)

Name

tuple_strstrtuple_strstrTupleStrstrTupleStrstrtuple_strstr — Forward search for strings within a string tuple.

Signature

tuple_strstr( : : String, ToFind : Position)

Herror tuple_strstr(const char* String, const char* ToFind, Hlong* Position)

Herror T_tuple_strstr(const Htuple String, const Htuple ToFind, Htuple* Position)

void TupleStrstr(const HTuple& String, const HTuple& ToFind, HTuple* Position)

HTuple HTuple::TupleStrstr(const HTuple& ToFind) const

static void HOperatorSet.TupleStrstr(HTuple stringVal, HTuple toFind, out HTuple position)

HTuple HTuple.TupleStrstr(HTuple toFind)

def tuple_strstr(string: MaybeSequence[str], to_find: MaybeSequence[str]) -> Sequence[int]

def tuple_strstr_s(string: MaybeSequence[str], to_find: MaybeSequence[str]) -> int

Description

tuple_strstrtuple_strstrTupleStrstrTupleStrstrtuple_strstr searches within the strings of the input tuple StringStringStringstringValstring for the strings of the input tuple ToFindToFindToFindtoFindto_find. Both input tuples may only consist of strings. Otherwise tuple_strstrtuple_strstrTupleStrstrTupleStrstrtuple_strstr returns an error. If StringStringStringstringValstring contains only one string, all strings of ToFindToFindToFindtoFindto_find are searched in it. Thus, the output tuple consists of as many elements as ToFindToFindToFindtoFindto_find. Whenever a searched string has been found, the position of its first occurrence gets stored in the output tuple PositionPositionPositionpositionposition (positions in strings are counted starting with 0). If a string can not be found, -1 will be returned instead of its position. If both input tuples show the same number of elements, the strings are searched elementwise. I.e., the first string of ToFindToFindToFindtoFindto_find is searched within the first string of StringStringStringstringValstring, the second string of ToFindToFindToFindtoFindto_find is searched within the second string of StringStringStringstringValstring and so on. The results of the elementwise searches are returned with PositionPositionPositionpositionposition that contains as many elements as StringStringStringstringValstring and ToFindToFindToFindtoFindto_find. If ToFindToFindToFindtoFindto_find only contains one string, this is searched within all strings of StringStringStringstringValstring. Thus, in this case PositionPositionPositionpositionposition consists of as many elements as StringStringStringstringValstring. If both input tuples contain more than one element and the number of elements differs for the input tuples, tuple_strstrtuple_strstrTupleStrstrTupleStrstrtuple_strstr returns an error.

If either or both of the input tuples are empty, the operator returns an empty tuple.

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')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_strstrtuple_strstrTupleStrstrTupleStrstrtuple_strstr, which can be used in an expression in the following syntax:

Position := strstr(String, ToFind)

Execution Information

Parameters

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

Input tuple with string(s) to examine.

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

Input tuple with string(s) to search.

PositionPositionPositionpositionposition (output_control)  integer(-array) HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Position of searched string(s) within the examined string(s).

Alternatives

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

Module

Foundation