Skip to content

tuple_regexp_testTupleRegexpTestTupleRegexpTesttuple_regexp_testtuple_regexp_test🔗

Short description🔗

tuple_regexp_testTupleRegexpTestTupleRegexpTesttuple_regexp_testtuple_regexp_test — Test if a string matches a regular expression.

Signature🔗

tuple_regexp_test( string Data, string Expression, out integer NumMatches )void TupleRegexpTest( const HTuple& Data, const HTuple& Expression, HTuple* NumMatches )static void HOperatorSet.TupleRegexpTest( HTuple data, HTuple expression, out HTuple numMatches )def tuple_regexp_test( data: MaybeSequence[str], expression: MaybeSequence[str] ) -> int

Herror tuple_regexp_test( const char* Data, const char* Expression, Hlong* NumMatches )

Herror T_tuple_regexp_test( const Htuple Data, const Htuple Expression, Htuple* NumMatches )

HTuple HTuple::TupleRegexpTest( const HTuple& Expression ) const

HTuple HTuple.TupleRegexpTest( HTuple expression )

Description🔗

tuple_regexp_testTupleRegexpTest applies the regular expression in Expressionexpressionexpression to one or more input strings in Datadatadata, and returns the number of matching strings in NumMatchesnumMatchesnum_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_matchTupleRegexpMatch for syntax and options of regular expressions. Additionally, tuple_regexp_testTupleRegexpTest supports the option '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'). 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_testTupleRegexpTest, which can be used in an expression in the following syntax:

NumMatches := regexp_test(Data, Expression)

or

texttt{NumMatches := 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"

NumMatchesnumMatchesnum_matches (output_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (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

Combinations with other operators🔗

Combinations

Alternatives

tuple_strstrTupleStrstr

See also

tuple_regexp_matchTupleRegexpMatch, tuple_regexp_replaceTupleRegexpReplace, tuple_regexp_selectTupleRegexpSelect

Module🔗

Foundation