tuple_regexp_select🔗
Short description🔗
tuple_regexp_select — Select tuple elements matching a regular expression.
Signature🔗
tuple_regexp_select( string Data, string Expression, out string Selection )
Description🔗
tuple_regexp_select applies the regular expression in
Expression to one or more input strings in Data,
and returns the matching string elements in Selection. This
is convenient, e.g., for filtering a list of files obtained using
the operator list_files.
Please refer to the documentation of tuple_regexp_match for syntax
and options of regular expressions. Additionally, tuple_regexp_select
supports the option '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' is set to 'locale' (legacy), this
operator always uses the byte mode.
HDevelop In-line Operation🔗
HDevelop provides an in-line operation for tuple_regexp_select,
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🔗
Data (input_control) string(-array) → (string)
Input strings to match.
Expression (input_control) string(-array) → (string)
Regular expression.
Default: '.*'
Suggested values: '.*', 'invert_match', 'ignore_case', 'multiline', 'dot_matches_all', 'newline_lf', 'newline_crlf', 'newline_cr'
Selection (output_control) string(-array) → (string)
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
See also
Module🔗
Foundation