ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dawson <>
Subject regexp file mapper question - inline replacing
Date Thu, 06 Dec 2001 20:40:36 GMT
A lot of the examples in specify how to
grab components of a filename and move them around, add things, etc. 

For example,
<mapper type="regexp" from="^(.*)\.java$$" to="\"/>
foo/bar/ -> foo/bar/

<mapper type="regexp" from="^(.*)/([^/]+)/([^/]*)$$" to="\1/\2/\2-\3"/>
foo/bar/ -> foo/bar/

<mapper type="regexp" from="^(.*)\.(.*)$$" to="\2.\1"/>
foo/bar/ ->

...but what I want to do is a little different. I want to do a
search/replace of a given character... in this case, replace directory
separators with dot files (and while I'm at it, strip an extension).  this
would be easy if I knew how deep the subdirectory tree would always be, but
I don't...

foo/A.txt         -> foo.A
foo/bar/B.txt     ->
foo/bar/baz/C.txt ->

I don't quite see how the current from/to attributes for mapper will get me
there, since it seems to need to know up front what you're matching & how
many of them there are, in order to do the substitutions. For example, 

<mapper type="regexp" from="^(.*)/(.*)/(.*)\.txt$$" to="\1.\2.\3"/>
would work for "foo/bar/B.txt" but not for "foo/A.txt" or

Is there something I'm missing for how to use mapper? Or is the capability
I'm looking for simply not present?



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

View raw message