2006-09-11 04:19:00 +00:00
|
|
|
<!--
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
2003-12-01 22:03:25 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
2005-04-29 18:58:16 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
2003-12-01 22:03:25 +00:00
|
|
|
<title>Regexp Type</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2018-02-08 16:59:52 +01:00
|
|
|
<h2 id="regexp">Regexp</h2>
|
2003-12-01 22:03:25 +00:00
|
|
|
<p>
|
|
|
|
Regexp represents a regular expression.
|
|
|
|
<h3>Parameters</h3>
|
2018-02-28 17:02:48 +01:00
|
|
|
<table class="attr">
|
2003-12-01 22:03:25 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<th>Attribute</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Required</th>
|
2003-12-01 22:03:25 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>pattern</td>
|
|
|
|
<td>regular expression pattern</td>
|
|
|
|
<td>Yes</td>
|
2003-12-01 22:03:25 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<h3>Examples</h3>
|
2018-02-09 06:54:03 +01:00
|
|
|
<pre><regexp id="myregexp" pattern="alpha(.+)beta"/></pre>
|
2003-12-01 22:03:25 +00:00
|
|
|
<p>
|
2018-02-28 07:58:59 +01:00
|
|
|
Defines a regular expression for later use with <var>id</var> <q>myregexp</q>.
|
2003-12-01 22:03:25 +00:00
|
|
|
</p>
|
2018-02-09 06:54:03 +01:00
|
|
|
<pre><regexp refid="myregexp"/></pre>
|
2003-12-01 22:03:25 +00:00
|
|
|
<p>
|
2018-02-28 07:58:59 +01:00
|
|
|
Use the regular expression with <var>id</var> <q>myregexp</q>.
|
2003-12-01 22:03:25 +00:00
|
|
|
</p>
|
2018-02-08 16:59:52 +01:00
|
|
|
<h3 id="implementation">Choice of regular expression implementation</h3>
|
2003-12-01 22:03:25 +00:00
|
|
|
<p>
|
2018-02-28 07:58:59 +01:00
|
|
|
Apache Ant comes with wrappers for
|
|
|
|
the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/package-summary.html"
|
|
|
|
target="_top">java.util.regex
|
|
|
|
package</a>, <a href="https://attic.apache.org/projects/jakarta-regexp.html"
|
|
|
|
target="_top">jakarta-regexp</a>
|
|
|
|
and <a href="https://attic.apache.org/projects/jakarta-oro.html" target="_top">jakarta-ORO</a>,
|
|
|
|
see <a href="../install.html#librarydependencies">installation dependencies</a> concerning the
|
|
|
|
supporting libraries.</p>
|
2003-12-01 22:03:25 +00:00
|
|
|
<p>
|
2018-02-28 07:58:59 +01:00
|
|
|
The property <code>ant.regexp.regexpimpl</code> governs which regular expression implementation
|
|
|
|
will be chosen. Possible values for this property are:</p>
|
2003-12-01 22:03:25 +00:00
|
|
|
<ul>
|
2018-02-28 07:58:59 +01:00
|
|
|
<li><code>org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp</code></li>
|
|
|
|
<li><code>org.apache.tools.ant.util.regexp.JakartaOroRegexp</code></li>
|
|
|
|
<li><code>org.apache.tools.ant.util.regexp.JakartaRegexpRegexp</code></li>
|
2003-12-01 22:03:25 +00:00
|
|
|
</ul>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>It can also be another implementation of the
|
|
|
|
interface <code>org.apache.tools.ant.util.regexp.Regexp</code>.
|
|
|
|
If <code>ant.regexp.regexpimpl</code> is not defined, Ant uses Jdk14Regexp as this is always
|
|
|
|
available.</p>
|
2003-12-01 22:03:25 +00:00
|
|
|
<p>
|
2018-02-28 07:58:59 +01:00
|
|
|
There are cross-platform issues for matches related to line terminator. For example if you
|
|
|
|
use <q>$</q> to anchor your regular expression on the end of a line the results might be very
|
|
|
|
different depending on both your platform and the regular expression library you use. It
|
|
|
|
is <em>highly recommended</em> that you test your pattern on both Unix and Windows platforms
|
|
|
|
before you rely on it.</p>
|
2003-12-01 22:03:25 +00:00
|
|
|
<ul>
|
2018-02-28 07:58:59 +01:00
|
|
|
<li>Jakarta Oro defines a line terminator as <q>\n</q> and is consistent with Perl.</li>
|
|
|
|
<li>Jakarta RegExp uses a system-dependent line terminator.</li>
|
|
|
|
<li>JDK 1.4 uses <q>\n</q>, <q>\r\n</q>, <q>\u0085</q>, <q>\u2028</q>, <q>\u2029</q> as a
|
|
|
|
default but is configured in the wrapper to use only <q>\n</q> (UNIX_LINE)</li>
|
2003-12-01 22:03:25 +00:00
|
|
|
</ul>
|
2018-02-08 16:59:52 +01:00
|
|
|
<p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<em>We used to recommend that you use Jakarta ORO but since its development has been retired
|
|
|
|
Java's built-in regex package is likely the best choice going forward.</em>
|
2003-12-01 22:03:25 +00:00
|
|
|
</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<h3>Usage</h3> The following tasks and types use the Regexp type:
|
2003-12-01 22:03:25 +00:00
|
|
|
<ul>
|
2010-05-26 20:33:51 +00:00
|
|
|
<li><a href="../Tasks/replaceregexp.html">ReplaceRegExp task</a></li>
|
2003-12-01 22:03:25 +00:00
|
|
|
<li><a href="filterchain.html#linecontainsregexp">LineContainsRegexp filter</a></li>
|
|
|
|
</ul>
|
|
|
|
<p>
|
2018-02-28 07:58:59 +01:00
|
|
|
These string filters also use the mechanism of regexp to choose a regular expression
|
|
|
|
implementation:
|
2003-12-01 22:03:25 +00:00
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li><a href="filterchain.html#containsregex">ContainsRegex string filter</a></li>
|
|
|
|
<li><a href="filterchain.html#replaceregex">ReplaceRegex string filter</a></li>
|
2009-08-27 11:29:32 +00:00
|
|
|
<li><a href="selectors.html#filenameselect">filename selector</a></li>
|
|
|
|
<li><a href="resources.html#rsel.name">name resource selector</a></li>
|
|
|
|
<li><a href="selectors.html#regexpselect">containsregexp selector</a></li>
|
2003-12-01 22:03:25 +00:00
|
|
|
</ul>
|
2006-09-11 04:33:25 +00:00
|
|
|
|
2003-12-01 22:03:25 +00:00
|
|
|
</body>
|
2005-04-29 18:01:43 +00:00
|
|
|
</html>
|