tuple_strchrtuple_strchrTupleStrchrTupleStrchrtuple_strchr (算子)

名称

tuple_strchrtuple_strchrTupleStrchrTupleStrchrtuple_strchr — 正向搜索字符串元组中的字符。

签名

tuple_strchr( : : String, ToFind : Position)

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

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

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

HTuple HTuple::TupleStrchr(const HTuple& ToFind) const

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

HTuple HTuple.TupleStrchr(HTuple toFind)

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

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

描述

tuple_strchrtuple_strchrTupleStrchrTupleStrchrTupleStrchrtuple_strchr searches within the strings of the input tuple StringStringStringStringstringValstring for the characters of the input tuple ToFindToFindToFindToFindtoFindto_find. Both input tuples may only consist of strings. Otherwise tuple_strchrtuple_strchrTupleStrchrTupleStrchrTupleStrchrtuple_strchr returns an error. If the elements of ToFindToFindToFindToFindtoFindto_find contain more than one character, only the first character of each element is considered for searching. If StringStringStringStringstringValstring contains only one string, all the characters defined in ToFindToFindToFindToFindtoFindto_find are searched in this string. Thus, the output tuple consists of as many elements as ToFindToFindToFindToFindtoFindto_find. Whenever a searched character has been found, the position of its first occurrence gets stored in the output tuple PositionPositionPositionPositionpositionposition (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 ToFindToFindToFindToFindtoFindto_find is searched within the first string of StringStringStringStringstringValstring, the first character of the second element of ToFindToFindToFindToFindtoFindto_find is searched within the second string of StringStringStringStringstringValstring and so on. The results of the elementwise searches are returned with PositionPositionPositionPositionpositionposition that contains as many elements as StringStringStringStringstringValstring and ToFindToFindToFindToFindtoFindto_find. If ToFindToFindToFindToFindtoFindto_find only contains one string, its first character is searched within all strings of StringStringStringStringstringValstring. Thus, in this case PositionPositionPositionPositionpositionposition consists of as many elements as StringStringStringStringstringValstring. If both input tuples contain more than one element and the number of elements differs for the input tuples, tuple_strchrtuple_strchrTupleStrchrTupleStrchrTupleStrchrtuple_strchr returns an error.

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

Unicode 码点与字节

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")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 内联操作

HDevelop provides an in-line operation for tuple_strchrtuple_strchrTupleStrchrTupleStrchrTupleStrchrtuple_strchr, which can be used in an expression in the following syntax:

Position := strchr(String, ToFind)

执行信息

参数

StringStringStringStringstringValstring (输入控制)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Input tuple with string(s) to examine.

ToFindToFindToFindToFindtoFindto_find (输入控制)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Input tuple with character(s) to search.

PositionPositionPositionPositionpositionposition (输出控制)  integer(-array) HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

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

替代

tuple_strrchrtuple_strrchrTupleStrrchrTupleStrrchrTupleStrrchrtuple_strrchr, tuple_strstrtuple_strstrTupleStrstrTupleStrstrTupleStrstrtuple_strstr, tuple_strrstrtuple_strrstrTupleStrrstrTupleStrrstrTupleStrrstrtuple_strrstr, tuple_strlentuple_strlenTupleStrlenTupleStrlenTupleStrlentuple_strlen, tuple_substrtuple_substrTupleSubstrTupleSubstrTupleSubstrtuple_substr, tuple_str_first_ntuple_str_first_nTupleStrFirstNTupleStrFirstNTupleStrFirstNtuple_str_first_n, tuple_str_last_ntuple_str_last_nTupleStrLastNTupleStrLastNTupleStrLastNtuple_str_last_n, tuple_splittuple_splitTupleSplitTupleSplitTupleSplittuple_split, tuple_environmenttuple_environmentTupleEnvironmentTupleEnvironmentTupleEnvironmenttuple_environment

模块

基础