Skip to content

tuple_regexp_selectTupleRegexpSelectTupleRegexpSelecttuple_regexp_selecttuple_regexp_select🔗

Short description🔗

tuple_regexp_selectTupleRegexpSelectTupleRegexpSelecttuple_regexp_selecttuple_regexp_select — Select tuple elements matching a regular expression.

Signature🔗

tuple_regexp_select( string Data, string Expression, out string Selection )void TupleRegexpSelect( const HTuple& Data, const HTuple& Expression, HTuple* Selection )static void HOperatorSet.TupleRegexpSelect( HTuple data, HTuple expression, out HTuple selection )def tuple_regexp_select( data: MaybeSequence[str], expression: MaybeSequence[str] ) -> Sequence[str]

def tuple_regexp_select_s( data: MaybeSequence[str], expression: MaybeSequence[str] ) -> strHerror tuple_regexp_select( const char* Data, const char* Expression, char* Selection )

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

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

HTuple HTuple.TupleRegexpSelect( HTuple expression )

Description🔗

tuple_regexp_selectTupleRegexpSelect applies the regular expression in Expressionexpressionexpression to one or more input strings in Datadatadata, and returns the matching string elements in Selectionselectionselection. This is convenient, e.g., for filtering a list of files obtained using the operator list_filesListFiles.

Please refer to the documentation of tuple_regexp_matchTupleRegexpMatch for syntax and options of regular expressions. Additionally, tuple_regexp_selectTupleRegexpSelect supports the option '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 code points versus bytes🔗

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'). If 'filename_encoding'"filename_encoding" is set to 'locale'"locale" (legacy), this operator always uses the byte mode.

HDevelop In-line Operation🔗

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

Selection := regexp_select(Data, Expression)

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🔗

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

Input strings to match.

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

Regular expression.

Default: '.*'".*"
Suggested values: '.*', 'invert_match', 'ignore_case', 'multiline', 'dot_matches_all', 'newline_lf', 'newline_crlf', 'newline_cr'".*", "invert_match", "ignore_case", "multiline", "dot_matches_all", "newline_lf", "newline_crlf", "newline_cr"

Selectionselectionselection (output_control) string(-array) → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Matching strings

Example🔗

(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'

Combinations with other operators🔗

Combinations

Alternatives

tuple_selectTupleSelect

See also

tuple_regexp_matchTupleRegexpMatch, tuple_regexp_replaceTupleRegexpReplace, tuple_regexp_testTupleRegexpTest

Module🔗

Foundation