tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select (算子)

名称

tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select — 选择与正则表达式匹配的元组元素。

签名

tuple_regexp_select( : : Data, Expression : Selection)

Herror tuple_regexp_select(const char* Data, const char* Expression, char* Selection)

Herror T_tuple_regexp_select(const Htuple Data, const Htuple Expression, Htuple* Selection)

void TupleRegexpSelect(const HTuple& Data, const HTuple& Expression, HTuple* Selection)

HTuple HTuple::TupleRegexpSelect(const HTuple& Expression) const

static void HOperatorSet.TupleRegexpSelect(HTuple data, HTuple expression, out HTuple selection)

HTuple HTuple.TupleRegexpSelect(HTuple expression)

def tuple_regexp_select(data: MaybeSequence[str], expression: MaybeSequence[str]) -> Sequence[str]

def tuple_regexp_select_s(data: MaybeSequence[str], expression: MaybeSequence[str]) -> str

描述

tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select applies the regular expression in ExpressionExpressionExpressionExpressionexpressionexpression to one or more input strings in DataDataDataDatadatadata, and returns the matching string elements in SelectionSelectionSelectionSelectionselectionselection. This is convenient, e.g., for filtering a list of files obtained using the operator list_fileslist_filesListFilesListFilesListFileslist_files

Please refer to the documentation of tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatchTupleRegexpMatchtuple_regexp_match for syntax and options of regular expressions. Additionally, tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select supports the option 'invert_match'"invert_match""invert_match""invert_match""invert_match""invert_match", which causes those input strings to be selected which do not match the regular expression.

For general information about string operations see Tuple / String Operations

If the input tuple is empty, the operator returns an empty tuple.

Unicode 码点与字节

Regular expression matching operates on Unicode code points. One Unicode code point may be composed of multiple bytes in the UTF-8 string. If regular expression matching should only match on bytes, 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.

HDevelop 内联操作

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

Selection := regexp_select(Data, Expression)

执行信息

参数

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

Input strings to match.

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

Regular expression.

默认值: '.*' ".*" ".*" ".*" ".*" ".*"

建议值: '.*'".*"".*"".*"".*"".*", 'invert_match'"invert_match""invert_match""invert_match""invert_match""invert_match", 'ignore_case'"ignore_case""ignore_case""ignore_case""ignore_case""ignore_case", 'multiline'"multiline""multiline""multiline""multiline""multiline", 'dot_matches_all'"dot_matches_all""dot_matches_all""dot_matches_all""dot_matches_all""dot_matches_all", 'newline_lf'"newline_lf""newline_lf""newline_lf""newline_lf""newline_lf", 'newline_crlf'"newline_crlf""newline_crlf""newline_crlf""newline_crlf""newline_crlf", 'newline_cr'"newline_cr""newline_cr""newline_cr""newline_cr""newline_cr"

SelectionSelectionSelectionSelectionselectionselection (输出控制)  string(-array) HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Matching strings

示例(HDevelop)

tuple_regexp_select (['.','..','mydir','a.png','b.txt','c.bmp','d.dat'], \
                     '.(bmp|png)', Result)
* Returns ['a.png','c.bmp']

tuple_regexp_select (Files, ['training','invert_match'], Matches)
* Returns all file names that do *not* contain the string 'training'

替代

tuple_selecttuple_selectTupleSelectTupleSelectTupleSelecttuple_select

另见

tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatchTupleRegexpMatchtuple_regexp_match, tuple_regexp_replacetuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplaceTupleRegexpReplacetuple_regexp_replace, tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTestTupleRegexpTesttuple_regexp_test

模块

基础