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>
|
---|
12 | Regexp 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 | <regexp id="myregexp" pattern="alpha(.+)beta"/><br />
|
---|
30 | </pre></blockquote>
|
---|
31 | <p>
|
---|
32 | Defines a regular expression for later use with id myregexp.
|
---|
33 | </p>
|
---|
34 | <blockquote><pre>
|
---|
35 | <regexp refid="myregexp"/><br />
|
---|
36 | </pre></blockquote>
|
---|
37 | <p>
|
---|
38 | Use the regular expression with id myregexp.
|
---|
39 | </p>
|
---|
40 | <a name="implementation"/>
|
---|
41 | <h3>Choice of regular expression implementation</h3>
|
---|
42 | <p>
|
---|
43 | Ant comes with
|
---|
44 | wrappers 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>
|
---|
47 | and <a href="http://jakarta.apache.org/oro/" target="_top">jakarta-ORO</a>,
|
---|
48 | See <a href="../install.html#librarydependencies">installation dependencies</a>
|
---|
49 | concerning the supporting libraries.</p>
|
---|
50 | <p>
|
---|
51 | The property <code>ant.regexp.regexpimpl</code> governs which regular expression implementation will be chosen.
|
---|
52 | Possible values for this property are :
|
---|
53 | <ul>
|
---|
54 | <li>
|
---|
55 | org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp
|
---|
56 | </li>
|
---|
57 | <li>
|
---|
58 | org.apache.tools.ant.util.regexp.JakartaOroRegexp
|
---|
59 | </li>
|
---|
60 | <li>
|
---|
61 | org.apache.tools.ant.util.regexp.JakartaRegexpRegexp
|
---|
62 | </li>
|
---|
63 | </ul>
|
---|
64 | It can also be another implementation of the interface <code>org.apache.tools.ant.util.regexp.Regexp</code>.
|
---|
65 | If <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>
|
---|
68 | There are cross-platform issues for matches related to line terminator.
|
---|
69 | For example if you use $ to anchor your regular expression on the end of a line
|
---|
70 | the results might be very different depending on both your platform and the regular
|
---|
71 | expression library you use. It is 'highly recommended' that you test your pattern on
|
---|
72 | both 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>
|
---|
82 | The 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>
|
---|
88 | These 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 © 2003-2004 The Apache Software Foundation.
|
---|
96 | All rights Reserved.</p>
|
---|
97 | </body>
|
---|
98 | </html> |
---|