blob: 33b855e47d865955520b1e3a1b5c5947656716fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Ant-contrib Tasks: PropertyRegex</title>
</head>
<body>
<h1>PropertyRegex</h1>
<p>Performs regular expression operations on an input string, and sets
the results to a property. There are two different operations that
can be performed:
<ol type="1">
<li>Replacement - The matched regular expression is replaced with
a substitition pattern</li>
<li>Selection - Groupings within the regular expression are selected
via a selection expression.
</ol>
</p>
<h2>Parameters</h2>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Required</th>
</tr>
<tr>
<td valign="top">property</td>
<td valign="top">The name of the property to set.</td>
<td align="center" valign="top">Yes.</td>
</tr>
<tr>
<td valign="top">override</td>
<td valign="top">If the property is already set, should we change it's value.
Can be <code>true</code> or <code>false</code></td>
<td align="center" valign="top">No. Defaults to <code>false</code></td>
</tr>
<tr>
<td valign="top">input</td>
<td valign="top">The input string to be processed</td>
<td align="center" valign="top">Yes.</td>
</tr>
</tr>
<tr>
<td valign="top">regexp</td>
<td valign="top">The regular expression which is matched in
the input string.</td>
<td align="center" valign="top">Yes (can be specified in a
<code><regexp></code> subelement).
</td>
</tr>
<tr>
<td valign="top">select</td>
<td valign="top">A pattern which indicates what selection 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.</td>
<td align="center" valign="top">Yes, unless a replace is specified</td>
</tr>
<tr>
<td valign="top">replace</td>
<td valign="top">A regular expression substitition pattern, which will be used
to replace the given regular expression in the input string.</td>
<td align="center" valign="top">Yes, unless a select is specified</td>
</tr>
<tr>
<td valign="top">casesensitive</td>
<td valign="top">Should the match be case sensitive</td>
<td align="center" valign="top">No. default is "true".</td>
</tr>
<tr>
<td valign="top">global</td>
<td valign="top">Should a replacement operation be performed on the entire
string, rather than just the first occurance</td>
<td align="center" valign="top">No. default is <code>false</code>.</td>
</tr>
<tr>
<td valign="top">defaultValue</td>
<td valign="top">The value to set the output property to, if the
input string does not match the specific regular expression.</td>
<td align="center" valign="top">No.</td>
</table>
<h2>Select expressions</h2>
Expressions are selected in a the same syntax as a regular expression
substitution pattern.
<ul type="o">
<li><code>\0</code> indicates the entire property name (default).
<li><code>\1</code> indicates the first grouping
<li><code>\2</code> indicates the second grouping
<li>etc...
</ul>
<h2>Replacement</h2>
It is important to note that when doing a "replace" operation,
if the input 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.
<h2>Example</h2>
<pre>
<code>
<propertyregex property="pack.name"
input="package.ABC.name"
regexp="package\.([^\.]*)\.name"
select="\1"
casesensitive="false" />
</code>
yields <code>ABC</code>
</pre>
<pre>
<code>
<propertyregex property="pack.name"
input="package.ABC.name"
regexp="(package)\.[^\.]*\.(name)"
replace="\1.DEF.\2"
casesensitive="false" />
</code>
yields <code>package.DEF.name</code>
</pre>
<hr>
<p align="center">Copyright © 2003 Ant-Contrib Project. All
rights Reserved.</p>
</body>
</html>
|