ClassesClasses | | Operators

tuple_regexp_replacetuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplace (Operator)

Name

tuple_regexp_replacetuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplace — Replace a substring using regular expressions.

Signature

tuple_regexp_replace( : : Data, Expression, Replace : Result)

Herror tuple_regexp_replace(const char* Data, const char* Expression, const char* Replace, char* Result)

Herror T_tuple_regexp_replace(const Htuple Data, const Htuple Expression, const Htuple Replace, Htuple* Result)

void TupleRegexpReplace(const HTuple& Data, const HTuple& Expression, const HTuple& Replace, HTuple* Result)

HTuple HTuple::TupleRegexpReplace(const HTuple& Expression, const HTuple& Replace) const

static void HOperatorSet.TupleRegexpReplace(HTuple data, HTuple expression, HTuple replace, out HTuple result)

HTuple HTuple.TupleRegexpReplace(HTuple expression, HTuple replace)

Description

tuple_regexp_replacetuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplaceTupleRegexpReplace applies the regular expression in ExpressionExpressionExpressionExpressionexpression to one or more input strings in DataDataDataDatadata, and replaces the first matching substring using the ReplaceReplaceReplaceReplacereplace expression. For each input string, a processed output string is returned in ResultResultResultResultresult.

Please refer to the documentation of tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatchTupleRegexpMatch for syntax and options of regular expressions. Additionally, tuple_regexp_replacetuple_regexp_replaceTupleRegexpReplaceTupleRegexpReplaceTupleRegexpReplace supports the option 'replace_all'"replace_all""replace_all""replace_all""replace_all", which causes all matches within each individual string to be replaced.

The ReplaceReplaceReplaceReplacereplace expression may use the tag '$0'"$0""$0""$0""$0" to refer to the matched substring in the input data, '$i'"$i""$i""$i""$i" to refer to the submatch of the i-th capturing group (for i <= 9), and '$$'"$$""$$""$$""$$" to refer to the '$'"$""$""$""$" literal.

For general information about string operations see Tuple / String Operations.

Exception: Empty input tuple

If DataDataDataDatadata is an empty tuple, the operator returns an empty tuple. If ReplaceReplaceReplaceReplacereplace is an empty tuple and DataDataDataDatadata is not empty, an exception is raised.

HDevelop In-line Operation

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

Result := regexp_replace(Data, Expression, Replace)

Execution Information

Parameters

DataDataDataDatadata (input_control)  string(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Input strings to process.

ExpressionExpressionExpressionExpressionexpression (input_control)  string(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Regular expression.

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

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

ReplaceReplaceReplaceReplacereplace (input_control)  string HTupleHTupleHtuple (string) (string) (HString) (char*)

Replacement expression.

ResultResultResultResultresult (output_control)  string(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Processed strings.

Example (HDevelop)

tuple_regexp_replace(['img10.bmp','img11.bmp','img12.bmp'], \
                     'img(.*).bmp', 'out$1.txt', Result)
* Returns ['out10.txt','out11.txt','out12.txt']

See also

tuple_regexp_matchtuple_regexp_matchTupleRegexpMatchTupleRegexpMatchTupleRegexpMatch, tuple_regexp_testtuple_regexp_testTupleRegexpTestTupleRegexpTestTupleRegexpTest, tuple_regexp_selecttuple_regexp_selectTupleRegexpSelectTupleRegexpSelectTupleRegexpSelect

Module

Foundation


ClassesClasses | | Operators