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-08 16:59:52 +01:00
|
|
|
<table>
|
2003-12-01 22:03:25 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top"><b>Attribute</b></td>
|
|
|
|
<td valign="top"><b>Description</b></td>
|
|
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">pattern</td>
|
|
|
|
<td valign="top">regular expression pattern</td>
|
|
|
|
<td valign="top" align="center">Yes</td>
|
|
|
|
</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>
|
|
|
|
Defines a regular expression for later use with id myregexp.
|
|
|
|
</p>
|
2018-02-09 06:54:03 +01:00
|
|
|
<pre><regexp refid="myregexp"/></pre>
|
2003-12-01 22:03:25 +00:00
|
|
|
<p>
|
|
|
|
Use the regular expression with id myregexp.
|
|
|
|
</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>
|
2010-11-11 17:04:16 +00:00
|
|
|
Apache Ant comes with
|
2003-12-01 22:03:25 +00:00
|
|
|
wrappers for
|
2013-09-13 13:40:23 +00:00
|
|
|
<a href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/package-summary.html" target="_top">the java.util.regex package</a>,
|
2011-07-18 06:46:28 +00:00
|
|
|
<a href="http://attic.apache.org/projects/jakarta-regexp.html" target="_top">jakarta-regexp</a>
|
|
|
|
and <a href="http://attic.apache.org/projects/jakarta-oro.html" target="_top">jakarta-ORO</a>,
|
2003-12-01 22:03:25 +00:00
|
|
|
See <a href="../install.html#librarydependencies">installation dependencies</a>
|
|
|
|
concerning the supporting libraries.</p>
|
|
|
|
<p>
|
|
|
|
The property <code>ant.regexp.regexpimpl</code> governs which regular expression implementation will be chosen.
|
2018-02-08 16:59:52 +01:00
|
|
|
Possible values for this property are:</p>
|
2003-12-01 22:03:25 +00:00
|
|
|
<ul>
|
2018-02-09 06:54:03 +01:00
|
|
|
<li>org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp</li>
|
|
|
|
<li>org.apache.tools.ant.util.regexp.JakartaOroRegexp</li>
|
|
|
|
<li>org.apache.tools.ant.util.regexp.JakartaRegexpRegexp</li>
|
2003-12-01 22:03:25 +00:00
|
|
|
</ul>
|
2018-02-08 16:59:52 +01:00
|
|
|
<p>It can also be another implementation of the interface <code>org.apache.tools.ant.util.regexp.Regexp</code>.
|
2009-08-26 19:42:25 +00:00
|
|
|
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>
|
|
|
|
There are cross-platform issues for matches related to line terminator.
|
|
|
|
For example if you use $ 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 'highly recommended' that you test your pattern on
|
2018-02-08 16:59:52 +01:00
|
|
|
both Unix and Windows platforms before you rely on it.</p>
|
2003-12-01 22:03:25 +00:00
|
|
|
<ul>
|
|
|
|
<li>Jakarta Oro defines a line terminator as '\n' and is consistent with Perl.</li>
|
2009-08-26 19:42:25 +00:00
|
|
|
<li>Jakarta RegExp uses a system-dependent line terminator.</li>
|
2003-12-01 22:03:25 +00:00
|
|
|
<li>JDK 1.4 uses '\n', '\r\n', '\u0085', '\u2028', '\u2029' as a default
|
|
|
|
but is configured in the wrapper to use only '\n' (UNIX_LINE)</li>
|
|
|
|
</ul>
|
2018-02-08 16:59:52 +01:00
|
|
|
<p>
|
2011-07-18 06:46:28 +00: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>
|
|
|
|
<h3>Usage</h3>
|
|
|
|
The following tasks and types use the Regexp type :
|
|
|
|
<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>
|
|
|
|
These string filters also use the mechanism of regexp to choose a regular expression implementation :
|
|
|
|
</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>
|