ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis GALIEGUE <>
Subject Re: regexp-type <mapper> doesn't work as expected/(advertised?)
Date Thu, 22 Oct 2009 08:39:33 GMT
On Wed, Oct 21, 2009 at 08:33, Stefan Bodewig <> wrote:
>> I then suggest that the documentation be reviewed to say that the
>> regex must match all the filename.
> This is not really true, it doesn't matter whether the match is all of
> the file name or only part of it, the key is that the to attribute
> provides the target file name and nothing else - in particular not parts
> of the source file name that are not matched.
> The documentation currently says
> ,----
> | If the source file name matches the from pattern, the target file name
> | will be constructed from the to pattern, using \0 to \9 as
> | back-references for the full match (\0) or the matches of the
> | subexpressions in parentheses.
> `----
> If you can come up with a clearer way to say what the target file name
> is going to be, I'll happily change the wording.

What about:

The source filename is matched, in whole or in part, by the "from"
pattern. The resulting filename is built using the "to" pattern, which
can use backreferences (\0, \1, ...). Warning: unlike what happens
with a casual regex substitution operation (f.e. perl's "s//"
operator, Java's .replaceAll(), etc), the "to" pattern here is used to
construct the _whole_ resulting filename. Therefore, if you want to,
for instance, replace the extension of a file with a regex mapper, you
should _not_ write:

from="\.old$" to=".new"


from="'(.*)\.old$" to="\"

(although for this particular case, you'd probably want to use a
globmapper instead).


Francis Galiegue
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
40 avenue Raymond Poincaré
75116 Paris

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message