从ant属性中删除最后三个字符

时间:2014-10-27 04:49:20

标签: ant

我有一个ant属性,其值为abcdefghijklmn

我想从属性中删除最后三个字符到abcdefghijk。

请帮忙。

1 个答案:

答案 0 :(得分:0)

实施例

build:
     [echo] x = abcdefghijklmn
     [echo] y = abcdefghijk

的build.xml

<project name="demo" default="build">

  <property name="x" value="abcdefghijklmn"/>

  <target name="build">
    <script language="javascript">
      project.setProperty("y", project.getProperty("x").substr(0,11));
    </script>

    <echo message="x = ${x}"/>
    <echo message="y = ${y}"/>
  </target>

</project>