regex

Purpose

Extracts a substring from the input string and formats the extracted substring as specified by regular expression.

Syntax

regex($group, <regex>, <format_regex>)

Arguments

The first argument is an input string (reference to a named group or a constant) to be modified.

The second argument <regex> is a regular expression that specifies what substring to extract from the input string.

The third argument <format_regex> is a regular expression that specifies how to format the extracted substring. If the argument is omitted, the extracted substring is output as is.

Returned Value

A string value.

Examples

Dataset

XPDL-rule

Result

03.15.2002

rule: r1

{

query: {regex("\d\d\.\d\d.\d\d\d\d")}:m

result: Match = $m

attribute: Month = regex($m, "^\d\d")

attribute: Day = regex($m, "^\d\d\.(\d\d)", "\1")

attribute: YYYYMMDD = regex($m, "(\d\d)\.(\d\d).(\d\d\d\d)", "\3-\1-\2")

}

Match: 03.15.2002

Month:03

Day:15

YYYYMMDD: 2002-03-15