source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/docs/manual/CoreTypes/regexp.html@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 3.5 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Regexp Type</title>
6</head>
7
8<body>
9
10<h2><a name="regexp">Regexp</a></h2>
11<p>
12Regexp represents a regular expression.
13<h3>Parameters</h3>
14<table border="1" cellpadding="2" cellspacing="0">
15 <tr>
16 <td valign="top"><b>Attribute</b></td>
17 <td valign="top"><b>Description</b></td>
18 <td align="center" valign="top"><b>Required</b></td>
19 </tr>
20 <tr>
21 <td valign="top">pattern</td>
22 <td valign="top">regular expression pattern</td>
23 <td valign="top" align="center">Yes</td>
24 </tr>
25</table>
26
27<h3>Examples</h3>
28<blockquote><pre>
29 &lt;regexp id="myregexp" pattern="alpha(.+)beta"/&gt;<br />
30</pre></blockquote>
31<p>
32Defines a regular expression for later use with id myregexp.
33</p>
34<blockquote><pre>
35 &lt;regexp refid="myregexp"/&gt;<br />
36</pre></blockquote>
37<p>
38Use the regular expression with id myregexp.
39</p>
40<a name="implementation"/>
41<h3>Choice of regular expression implementation</h3>
42<p>
43Ant comes with
44wrappers for
45<a href="http://java.sun.com/j2se/1.4/docs/api/java/util/regex/package-summary.html" target="_top">the java.util.regex package of JDK 1.4</a>,
46<a href="http://jakarta.apache.org/regexp/" target="_top">jakarta-regexp</a>
47and <a href="http://jakarta.apache.org/oro/" target="_top">jakarta-ORO</a>,
48See <a href="../install.html#librarydependencies">installation dependencies</a>
49 concerning the supporting libraries.</p>
50<p>
51The property <code>ant.regexp.regexpimpl</code> governs which regular expression implementation will be chosen.
52Possible values for this property are :
53<ul>
54<li>
55org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp
56</li>
57<li>
58org.apache.tools.ant.util.regexp.JakartaOroRegexp
59</li>
60<li>
61org.apache.tools.ant.util.regexp.JakartaRegexpRegexp
62</li>
63</ul>
64It can also be another implementation of the interface <code>org.apache.tools.ant.util.regexp.Regexp</code>.
65If <code>ant.regexp.regexpimpl</code> is not defined, ant checks in the order Jdk14Regexp, JakartaOroRegexp,
66 JakartaRegexp for the availability of the corresponding library. The first of these 3 which is found will be used.</p>
67<p>
68There are cross-platform issues for matches related to line terminator.
69For example if you use $ to anchor your regular expression on the end of a line
70the results might be very different depending on both your platform and the regular
71expression library you use. It is 'highly recommended' that you test your pattern on
72both Unix and Windows platforms before you rely on it.
73<ul>
74 <li>Jakarta Oro defines a line terminator as '\n' and is consistent with Perl.</li>
75 <li>Jakarta RegExp uses a system-dependant line terminator.</li>
76 <li>JDK 1.4 uses '\n', '\r\n', '\u0085', '\u2028', '\u2029' as a default
77 but is configured in the wrapper to use only '\n' (UNIX_LINE)</li>
78</ul>
79<em>We <b>strongly</b> recommend that you use Jakarta Oro.</em>
80</p>
81<h3>Usage</h3>
82The following tasks and types use the Regexp type :
83<ul>
84<li><a href="../OptionalTasks/replaceregexp.html">ReplaceRegExp task</a></li>
85<li><a href="filterchain.html#linecontainsregexp">LineContainsRegexp filter</a></li>
86</ul>
87<p>
88These string filters also use the mechanism of regexp to choose a regular expression implementation :
89</p>
90<ul>
91<li><a href="filterchain.html#containsregex">ContainsRegex string filter</a></li>
92<li><a href="filterchain.html#replaceregex">ReplaceRegex string filter</a></li>
93</ul>
94<hr>
95<p align="center">Copyright &copy; 2003-2004 The Apache Software Foundation.
96All rights Reserved.</p>
97</body>
98</html>
Note: See TracBrowser for help on using the repository browser.