ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "DJ Kingsolver" <dkingsol...@gmail.com>
Subject Re: String Manipulation
Date Sun, 13 Jan 2008 16:12:36 GMT
Thanks for your help David. I was already including the antcontib tasks
(needed them for a foreach loop), but just not fully aware of what was in
there.  The propertyregex task worked perfectly for me, when reading up on
it I learned about a few other tasks that I know will come in handy soon.
Thanks again,
DJ

On 1/9/08, David Weintraub <qazwart@gmail.com> wrote:
>
> Try this using the AntContrib <propertyregex> task:
>
> <project name="test" default="test" basedir=".">
>     <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
>     <target name="test">
>         <property name="string.in" value="foo/bar/fubar"/>
>         <propertyregex
>             property="string.out"
>             input="${string.in}"
>             regexp="/"
>             replace="_"/>
>         <echo message="The value is now &quot;${string.out}&quot;"/>
>     </target>
> </project>
>
>
> On Jan 8, 2008 7:57 PM, DJ Kingsolver <dkingsolver@gmail.com> wrote:
> > Hi all,
> >
> > I need to do a simple string manipulation, but I'm finding it harder
> than I
> > expected.
> >
> > Say I have a property like this:
> >   <property name="inputString" value="foo/bar/baz" />
> >
> > I'd like to set another property like this:
> >   <property name="outputString" value="${inputString (with '/' replaced
> with
> > '_')}" />
> >
> > So, <echo message="${outputString}" /> would write "[echo]  foo_bar_baz"
> >
> > What is a good way to achieve this?
> >
> > I've thought about writing inputString to a file and replacing the '/'
> with
> > '_' using <replace>, then reading the changed value back out of the
> file.
> > But I'd rather not have the overhead of writing to a file.
> >
> > Thanks for your help,
> > DJ
> >
>
>
>
> --
> --
> David Weintraub
> qazwart@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message