ClassesClassesClassesClasses | | | | Operators

tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatch (Operator)


tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatch — Extract substrings using regular expressions.


tuple_regexp_match( : : Data, Expression : Matches)

Herror tuple_regexp_match(const char* Data, const char* Expression, char* Matches)

Herror T_tuple_regexp_match(const Htuple Data, const Htuple Expression, Htuple* Matches)

Herror tuple_regexp_match(const HTuple& Data, const HTuple& Expression, char* Matches)

Herror tuple_regexp_match(const HTuple& Data, const HTuple& Expression, HTuple* Matches)

void TupleRegexpMatch(const HTuple& Data, const HTuple& Expression, HTuple* Matches)

HTuple HTuple::TupleRegexpMatch(const HTuple& Expression) const

void HOperatorSetX.TupleRegexpMatch(
[in] VARIANT Data, [in] VARIANT Expression, [out] VARIANT* Matches)

VARIANT HTupleX.TupleRegexpMatch(
[in] VARIANT Data, [in] VARIANT Expression)

static void HOperatorSet.TupleRegexpMatch(HTuple data, HTuple expression, out HTuple matches)

HTuple HTuple.TupleRegexpMatch(HTuple expression)


tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatch applies the regular expression in ExpressionExpressionExpressionExpressionExpressionexpression to one or more input strings in DataDataDataDataDatadata, and in each case returns the first matching substring in MatchesMatchesMatchesMatchesMatchesmatches. Normally, one output string is returned for each input string, the output string being empty if no match was found. However, if the regular expression contains capturing groups (see below), the behavior depends on the number of input strings: If there is only a single input string, the result is a tuple of all captured submatches. If there are multiple input strings, the output strings represent the matched pattern of the first capturing group.

A summary of regular expression syntax is provided here. Basically, each character in the regular expression represents a literal to match, except for the following symbols which have a special meaning (the described syntax is compatible with Perl):

^      Matches start of string
$      Matches end of string (a trailing newline is allowed)
.      Matches any character except newline
[...]  Matches any character literal listed in the brackets.
       If the first character is a '^', this matches any character
       except those in the list. You can use the '-' character as
       in '[A-Z0-9]' to select character ranges. Other characters
       lose their special meaning in brackets, except '\'.

*      Allows 0 or more repetitions of preceding literal or group
+      Allows 1 or more repetitions
?      Allows 0 or 1 repetitions
{n,m}  Allows n to m repetitions
{n}    Allows exactly n repetitions

       The repeat quantifiers above are greedy by default, i.e. they
       attempt to maximize the length of the match. Appending ? attempts
       to find a minimal match, e.g. +?

( )    Groups a subpattern and creates a capturing group.
       The substrings captured by this group will be stored separately.
(?: )  Groups a subpattern without creating a capturing group

\      Escapes any special symbol to treat it as a literal. Note that
       some host languages like HDevelop and C/C++ already use the backslash
       as a general escape character. In this case, '\\.'"\\.""\\.""\\.""\\.""\\." matches a
       literal dot while '\\\\'"\\\\""\\\\""\\\\""\\\\""\\\\" matches a literal backslash.
       Furthermore, there are some special codes (the capitalized
       version of each denoting the negation):
       \d,\D  Matches a digit
       \w,\W  Matches a letter, digit or underscore
       \s,\S  Matches a white space character
       \b,\B  Matches a word boundary

If the specified expression is syntactically incorrect, you will receive an error stating that the value of control parameter 2 is wrong. Additional details are displayed in a message box if set_system('do_low_error', 'true')set_system("do_low_error", "true")SetSystem("do_low_error", "true")set_system("do_low_error", "true")SetSystem("do_low_error", "true")SetSystem("do_low_error", "true") is set.

Furthermore, you can set some options by passing a string tuple for ExpressionExpressionExpressionExpressionExpressionexpression. In this case, the first element is used as the expression, and each additional element is treated as an option.



DataDataDataDataDatadata (input_control)  string(-array) HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Input strings to match.

ExpressionExpressionExpressionExpressionExpressionexpression (input_control)  string(-array) HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Regular expression.

Default value: '.*' ".*" ".*" ".*" ".*" ".*"

Suggested values: '.*'".*"".*"".*"".*"".*", '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"

MatchesMatchesMatchesMatchesMatchesmatches (output_control)  string(-array) HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Found matches.

Example (HDevelop)

tuple_regexp_match ('abba', 'a*b*', Result)
* Returns 'abb'

tuple_regexp_match ('abba', 'b*a*', Result)
* Returns 'a'

tuple_regexp_match ('abba', 'b+a*', Result)
* Returns 'bba'

tuple_regexp_match ('abba', '.a', Result)
* Returns 'ba'

tuple_regexp_match ('abba', '[ab]*', Result)
* Returns 'abba'

tuple_regexp_match (['img123','img124'], 'img(.*)', Result)
* Returns ['123','124']

tuple_regexp_match ('mydir/img001.bmp', 'img(.*)\\.(.*)', Result)
* Returns ['001','bmp']



See also

tuple_regexp_replacetuple_regexp_replaceTupleRegexpReplacetuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplace, tuple_regexp_testtuple_regexp_testTupleRegexpTesttuple_regexp_testTupleRegexpTestTupleRegexpTest, tuple_regexp_selecttuple_regexp_selectTupleRegexpSelecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelect


Perl Compatible Regular Expressions (PCRE),



ClassesClassesClassesClasses | | | | Operators