Skip to content

tuple_strstrTupleStrstrTupleStrstrtuple_strstrtuple_strstr🔗

Short description🔗

tuple_strstrTupleStrstrTupleStrstrtuple_strstrtuple_strstr — Forward search for strings within a string tuple.

Signature🔗

tuple_strstr( string String, string ToFind, out integer Position )void TupleStrstr( const HTuple& String, const HTuple& ToFind, HTuple* Position )static void HOperatorSet.TupleStrstr( HTuple stringVal, HTuple toFind, out HTuple position )def tuple_strstr( string: MaybeSequence[str], to_find: MaybeSequence[str] ) -> Sequence[int]

def tuple_strstr_s( string: MaybeSequence[str], to_find: MaybeSequence[str] ) -> intHerror tuple_strstr( const char* String, const char* ToFind, Hlong* Position )

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

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

HTuple HTuple.TupleStrstr( HTuple toFind )

Description🔗

tuple_strstrTupleStrstr searches within the strings of the input tuple StringstringValstring for the strings of the input tuple ToFindtoFindto_find. Both input tuples may only consist of strings. Otherwise tuple_strstrTupleStrstr returns an error. If StringstringValstring contains only one string, all strings of ToFindtoFindto_find are searched in it. Thus, the output tuple consists of as many elements as ToFindtoFindto_find. Whenever a searched string has been found, the position of its first occurrence gets stored in the output tuple Positionpositionposition (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 ToFindtoFindto_find is searched within the first string of StringstringValstring, the second string of ToFindtoFindto_find is searched within the second string of StringstringValstring and so on. The results of the elementwise searches are returned with Positionpositionposition that contains as many elements as StringstringValstring and ToFindtoFindto_find. If ToFindtoFindto_find only contains one string, this is searched within all strings of StringstringValstring. Thus, in this case Positionpositionposition consists of as many elements as StringstringValstring. If both input tuples contain more than one element and the number of elements differs for the input tuples, tuple_strstrTupleStrstr 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'). 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_strstrTupleStrstr, which can be used in an expression in the following syntax:

Position := strstr(String, ToFind)

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.

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

Input tuple with string(s) to search.

Positionpositionposition (output_control) integer(-array) → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

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

Combinations with other operators🔗

Combinations

Alternatives

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

Module🔗

Foundation