Performs regular expression operations on an subject string, and sets the results to a property. There are two different operations that can be performed:
Replace - The matched regular expression is replaced with a substitution pattern
Match - Groupings within the regular expression are matched via a selection expression.
Table B.47: Attributes
Name | Type | Description | Default | Required |
---|---|---|---|---|
property
|
String
| The name of the property to set. | n/a | Yes |
override
|
Boolean
| If the property is already set, should we change it's value. Can be true
or false
| false | No |
subject
|
String
| The subject to be processed | n/a | Yes |
pattern
|
String
| The regular expression pattern which is matched in the subject. | n/a | Yes |
match
|
String
| A pattern which indicates what match pattern you want in the returned value. This uses the substitution pattern syntax to indicate where to insert groupings created as a result of the regular expression match. | n/a | Yes (unless a replace is specified) |
replace
|
String
| A regular expression substitition pattern, which will be used to replace the given regular expression in the subject. | n/a | Yes (unless a match is specified) |
casesensitive
|
Boolean
| Should the match be case sensitive | true | No |
limit
|
Integer
| The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit). | -1 | No |
defaultValue
|
Integer
| The value to set the output property to, if the subject string does not match the specific regular expression. | n/a | No |
Expressions are matched in a the same syntax as a regular expression substitution pattern.
$0 indicates the entire property name (default).
$1 indicates the first grouping
$2 indicates the second grouping
etc...
It is important to note that when doing a "replace" operation, if the subject string does not match the regular expression, then the property is not set. You can change this behavior by supplying the "defaultValue" attribute. This attribute should contain the value to set the property to in this case.
$0 indicates the entire property name (default).
$1 indicates the first grouping
$2 indicates the second grouping
etc...
<propertyregex property="pack.name" subject="package.ABC.name" pattern="package\.([^.]*)\.name" match="$1" casesensitive="false" defaultvalue="test1"/> <echo message="${pack.name}"/> <propertyregex property="pack.name" override="true" subject="package.ABC.name" pattern="(package)\.[^.]*\.(name)" replace="$1.DEF.$2" casesensitive="false" defaultvalue="test2"/> <echo message="${pack.name}"/>