Searches the body for the given regular expression and optionally replaces found occurrences with specified pattern. If body is a list of values then the regexp processor is applied to every item and final execution result is the list.

Syntax

<regexp replace="true_or_false"
        max="max_found_occurrences"
        flag-canoneq="flag-canoneq"
        flag-caseinsensitive="flag-caseinsensitive"
        flag-dotall="flag-dotall"
        flag-multiline="flag-multiline"
        flag-unicodecase="flag-unicodecase">
    <regexp-pattern>
        body as pattern value
    </regexp-pattern>
    <regexp-source>
        body as the text source
    </regexp-source>
    [<regexp-result>
        body as the result
    </regexp-result>]
</regexp>

For each group inside the search pattern and for each found occurrence variables with names _<group_number> are created. See some Regular Expression tutorial for better explanation of groups.

Attributes

Name Required Default Description
replace no false Logical value telling if found occurrences of regular expression will be replaced. Valid values are: true/false or yes/no. If this value is true (yes), then the regexp-result needs to be specified with replacement value.
max no Limits the number of found pattern occurrences. There is no limit if it is not specified.
flag-canoneq no no Enables canonical equivalence.
flag-caseinsensitive no no Enables case-insensitive matching.
flag-dotall no yes Enables dotall mode.
flag-multiline no no Enables multiline mode.
flag-unicodecase no yes Enables Unicode-aware case folding.

Example #1

<regexp>
    <regexp-pattern>([_\w\d]*)[\s]*=[\s]*([\w\d\s]*+)[\,\.\;]*</regexp-pattern>
    <regexp-source>
        var1= test1, var2 = bla bla; index=16;
        city = Delhi,town=Kingston;
    </regexp-source>
    <regexp-result>
        <template>Value of variable "${_1}" is "${_2}"!</template>
    </regexp-result>
</regexp>

Here, regular expression is looking for specified pattern in two strings, producing as a result list of five values: Value of variable "var1" is "test1"!, Value of variable "var2" is "bla bla"! ...

Example #2

<regexp replace="true">
    <regexp-pattern>[\s]*[\,\.\;][\s]*</regexp-pattern>
    <regexp-source>
        var1= test1, var2 = bla bla; index=16; city = Delhi,town=Kingston;
    </regexp-source>
    <regexp-result>
        <template>|</template>
    </regexp-result>
</regexp>

Here, the regular expression replacement produces single value as the result: var1= test1|var2 = bla bla|index=16|city = Delhi|town=Kingston|.