tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTesttuple_regexp_test (Operator)
Name
tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTesttuple_regexp_test
— Test if a string matches a regular expression.
Signature
def tuple_regexp_test(data: MaybeSequence[str], expression: MaybeSequence[str]) -> int
Description
tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTesttuple_regexp_test
applies the regular expression in
ExpressionExpressionExpressionexpressionexpression
to one or more input strings in DataDataDatadatadata
,
and returns the number of matching strings in NumMatchesNumMatchesNumMatchesnumMatchesnum_matches
.
In particular, the result for a single input string will be 1
in case of a match, and 0 otherwise.
Please refer to the documentation of tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatchtuple_regexp_match
for syntax
and options of regular expressions. Additionally, tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTesttuple_regexp_test
supports the option 'invert_match'"invert_match""invert_match""invert_match""invert_match", which causes those input strings
to be counted which do not match the regular expression.
For convenient use in conditional
expressions, this functionality is also available as the
'=~'"=~""=~""=~""=~" operation in HDevelop.
For general information about string operations see
Tuple / String Operations.
If the input tuple is empty, the operator returns 0.
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')set_system("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" is set to 'locale'"locale""locale""locale""locale" (legacy), this
operator always uses the byte mode.
HDevelop In-line Operation
HDevelop provides an in-line operation for tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTesttuple_regexp_test
,
which can be used in an expression in the following syntax:
NumMatches := regexp_test(Data, Expression)
or
NumMatches := Data =~ Expression
Execution Information
- Multithreading type: independent (runs in parallel even with exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Parameters
DataDataDatadatadata
(input_control) string(-array) →
HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Input strings to match.
ExpressionExpressionExpressionexpressionexpression
(input_control) string(-array) →
HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Regular expression.
Default:
'.*'
".*"
".*"
".*"
".*"
Suggested values:
'.*'".*"".*"".*"".*", 'invert_match'"invert_match""invert_match""invert_match""invert_match", 'ignore_case'"ignore_case""ignore_case""ignore_case""ignore_case", 'multiline'"multiline""multiline""multiline""multiline", '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_crlf'"newline_crlf""newline_crlf""newline_crlf""newline_crlf", 'newline_cr'"newline_cr""newline_cr""newline_cr""newline_cr"
NumMatchesNumMatchesNumMatchesnumMatchesnum_matches
(output_control) integer →
HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Number of matching strings
Example (HDevelop)
tuple_regexp_test ('p10662599755', '[A-Z]*', Result)
* Returns 0
tuple_regexp_test ('p10662599755', ['[A-Z]*','ignore_case'], Result)
* Returns 1
Alternatives
tuple_strstrtuple_strstrTupleStrstrTupleStrstrtuple_strstr
See also
tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatchtuple_regexp_match
,
tuple_regexp_replacetuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplacetuple_regexp_replace
,
tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelecttuple_regexp_select
Module
Foundation