reference:evaluator:regex

RegEx(
     string:string,
     string:pattern,
     [string:replace],
     [string:pattern...],
     [string:replace...],
     [value:0],
     [string:flags]
)
bool or string

Arguments

string

String to match.

pattern

Pattern to match against.

replace

Optional. Optional replace pattern.

pattern...

Optional. Optional additional match pattern...

replace...

Optional. Optional additional replace string...

0

Optional. Literal value 0. This is only needed in order to specify flags without replace.

flags

Optional. Optional flags are:

cconsider case when performing the operation (case-sensitive)
eif pattern doesn't match for a replace operation, return an empty string

Return value

Match or replacement result.

Description

Performs a regular expression match against the provided string. The pattern must match the string exactly.

If a replace pattern is not specified, this function returns True if the provided string matches the pattern, and otherwise returns False.

If a replace pattern is specified, the result of the replacement is returned. You can specify multiple string/pattern pairs, to perform multiple replacements at once. If the input string doesn't match the pattern it is returned unchanged. You can also add # to the end of each search pattern to repeat the search and replace as many times as possible (i.e. "replace all").

The optional flags argument must be specified last. If no replace pattern is provided and you want to provide flags, you must pass a literal 0 for the third argument.

Example:

path = "C:\Projects\contoso_staging\2023\June";
Output(RegEx(path, "(.*)_staging\\(.*)", "\1\\\2"));
--> C:\Projects\contoso\2023\June

See also:
RegExS