Debian Codegraph @

manual/Types/regexp.html

raw
1 <!DOCTYPE html>
2 <!--
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 https://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 -->
18 <html lang="en">
19
20 <head>
21 <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22 <title>Regexp Type</title>
23 </head>
24
25 <body>
26
27 <h2 id="regexp">Regexp</h2>
28 <p>
29 Regexp represents a regular expression.
30 <h3>Parameters</h3>
31 <table class="attr">
32 <tr>
33 <th scope="col">Attribute</th>
34 <th scope="col">Description</th>
35 <th scope="col">Required</th>
36 </tr>
37 <tr>
38 <td>pattern</td>
39 <td>regular expression pattern</td>
40 <td>Yes</td>
41 </tr>
42 <tr>
43 <td>refid</td>
44 <td>Makes this <code>regexp</code>
45 a <a href="../using.html#references">reference</a> to
46 a <code>regexp</code> defined elsewhere. If specified no other
47 attributes or nested elements are allowed.</td>
48 <td>No</td>
49 </tr>
50 </table>
51
52 <h3>Examples</h3>
53 <pre>&lt;regexp id="myregexp" pattern="alpha(.+)beta"/&gt;</pre>
54 <p>Defines a regular expression for later use with <var>id</var> <q>myregexp</q>.</p>
55 <pre>&lt;regexp refid="myregexp"/&gt;</pre>
56 <p>Use the regular expression with <var>id</var> <q>myregexp</q>.</p>
57 <h3 id="implementation">Choice of regular expression implementation</h3>
58 <p>Apache Ant comes with wrappers for
59 the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/package-summary.html"
60 target="_top"><code>java.util.regex</code>
61 package</a>, <a href="https://attic.apache.org/projects/jakarta-regexp.html"
62 target="_top">jakarta-regexp</a> and <a href="https://attic.apache.org/projects/jakarta-oro.html"
63 target="_top">jakarta-ORO</a>, see <a href="../install.html#librarydependencies">installation
64 dependencies</a> concerning the supporting libraries.</p>
65 <p>The property <code>ant.regexp.regexpimpl</code> governs which regular expression implementation
66 will be chosen. Possible values for this property are:</p>
67 <ul>
68 <li><code class="code">org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp</code></li>
69 <li><code class="code">org.apache.tools.ant.util.regexp.JakartaOroRegexp</code></li>
70 <li><code class="code">org.apache.tools.ant.util.regexp.JakartaRegexpRegexp</code></li>
71 </ul>
72 <p>It can also be another implementation of the
73 interface <code class="code">org.apache.tools.ant.util.regexp.Regexp</code>.
74 If <code>ant.regexp.regexpimpl</code> is not defined, Ant uses Jdk14Regexp as this is always
75 available.</p>
76 <p>
77 There are cross-platform issues for matches related to line terminator. For example if you
78 use <q>$</q> to anchor your regular expression on the end of a line the results might be very
79 different depending on both your platform and the regular expression library you use. It
80 is <em>highly recommended</em> that you test your pattern on both Unix and Windows platforms before
81 you rely on it.</p>
82 <ul>
83 <li>Jakarta Oro defines a line terminator as <q>\n</q> and is consistent with Perl.</li>
84 <li>Jakarta RegExp uses a system-dependent line terminator.</li>
85 <li><code>java.util.regex</code> uses <q>\n</q>, <q>\r\n</q>, <q>\u0085</q>, <q>\u2028</q>, <q>\u2029</q> as a
86 default but is configured in the wrapper to use only <q>\n</q> (UNIX_LINE)</li>
87 </ul>
88 <p><em>We used to recommend that you use Jakarta ORO but since its development has been retired
89 Java's built-in regex package is likely the best choice going forward.</em></p>
90 <h3>Usage</h3> The following tasks and types use the Regexp type:
91 <ul>
92 <li><a href="../Tasks/replaceregexp.html">ReplaceRegExp task</a></li>
93 <li><a href="filterchain.html#linecontainsregexp">LineContainsRegexp filter</a></li>
94 </ul>
95 <p>These string filters also use the mechanism of regexp to choose a regular expression
96 implementation:</p>
97 <ul>
98 <li><a href="filterchain.html#containsregex">ContainsRegex string filter</a></li>
99 <li><a href="filterchain.html#replaceregex">ReplaceRegex string filter</a></li>
100 <li><a href="selectors.html#filenameselect">filename selector</a></li>
101 <li><a href="resources.html#rsel.name">name resource selector</a></li>
102 <li><a href="selectors.html#regexpselect">containsregexp selector</a></li>
103 </ul>
104
105 </body>
106 </html>