Sets project properties based on the evaluation of a regular expression.
The NAnt.Core.Tasks.RegexTask.Pattern
attribute must contain one or more
named grouping constructs, which represents the names of the
properties to be set. These named grouping constructs can be enclosed
by angle brackets (?<name>) or single quotes (?'name').
In the build file, use the XML element < to specify <,
and > to specify >.
The named grouping construct must not contain any punctuation and it
cannot begin with a number.
Parameters
Attribute | Type | Description | Required |
---|---|---|---|
input | string |
Represents the input for the regular expression.
|
True |
pattern | string |
Represents the regular expression to be evaluated.
|
True |
options |
A comma separated list of options to pass to the regex engine. The
default is
System.Text.RegularExpressions.RegexOptions.None .
|
False | |
failonerror | bool |
Determines if task failure stops the build, or is just reported.
The default is
true .
|
False |
if | bool |
If
true then the task will be executed; otherwise,
skipped. The default is true .
|
False |
unless | bool |
Opposite of
NAnt.Core.Task.IfDefined . If false
then the task will be executed; otherwise, skipped. The default is
false .
|
False |
verbose | bool |
Determines whether the task should report detailed build log messages.
The default is
false .
|
False |
Examples
Find the last word in the given string and stores it in the property
lastword
.
<regex pattern="(?'lastword'\w+)$" input="This is a test sentence" />
<echo message="${lastword}" />
Split the full filename and extension of a filename.
<regex pattern="^(?'filename'.*)\.(?'extension'\w+)$" input="d:\Temp\SomeDir\SomeDir\bla.xml" />
Split the path and the filename. (This checks for /
or \
as the path separator).
<regex pattern="^(?'path'.*(\\|/)|(/|\\))(?'file'.*)$" input="d:\Temp\SomeDir\SomeDir\bla.xml" />
Results in path=d:\Temp\SomeDir\SomeDir\
and file=bla.xml
.
Requirements
- Assembly
- NAnt
.Core .dll - Namespace
-
NAnt
.Core .Tasks