ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: [Misc] Split String
Date Tue, 24 Aug 2004 08:49:14 GMT
Not within the core directly.

With AntContrib you can loop around that
<for value="x;y;z" separator=";" param="cur">
  <sequential>
    <echo>current value is @{cur}</echo>
  </>
</>

Or with java.util.String.split() and <script>

The later one you can store as a <scriptdef>
    <scriptdef name="split" language="javascript">
         <attribute name="value"/>
         <attribute name="sep"/>
         <attribute name="prefix"/>
         <![CDATA[
             values = attributes.get("value").split(attributes.get("sep"));
             for(i=0; i<values.length; i++) {
                 project.setNewProperty(attributes.get("prefix")+i,
values[i]);
             }
         ]]>
    </scriptdef>

    <target name="testScriptdef">
        <split value="x;y;z" sep=";" prefix="sc."/>
        <echoproperties prefix="sc"/>
    </target>

Jan

> -----Urspr√ľngliche Nachricht-----
> Von: Marcel Stör [mailto:marcel@frightanic.com]
> Gesendet am: Dienstag, 24. August 2004 09:51
> An: user@ant.apache.org
> Betreff: [Misc] Split String
> 
> Hi,
> 
> Is it somehow possible to split a String in Ant? I'm reading 
> a property from
> a properties file and would like to split the property value 
> "x;y;z;" into
> three individual Strings "x", "y", "z".
> 
> Regards,
> Marcel
> 
> 
> ---------------------------------------------------------------------
> 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