ant 字符串操作:从字符串中提取字符 [英] ant string manipulation : extracting characters from a string

查看:64
本文介绍了ant 字符串操作:从字符串中提取字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个值为 1.0.0.123 的 ant 属性

I have an ant property which has value of the type 1.0.0.123

我想提取最后一个点之后的值,在本例中为123".我应该使用哪个蚂蚁任务以及如何使用?

I want to extract the value after the last dot, in this case that would be '123'. Which ant task should i use and how?

推荐答案

好的,我自己找到了答案,并且已经过测试.你只需要使用一点 javascript.

Ok i have found the answer myself and this is tested. you just gotta use a bit of javascript.

<target name="get build ctr">

    <script language="javascript">
        <![CDATA[

                // getting the value
                buildnumber = myproj.getProperty("build.number");
                index = buildnumber.lastIndexOf(".");
                counter = buildnumber.substring(index+1);
                myproj.setProperty("buildctr",counter);

            ]]>
    </script>

</target>

这篇关于ant 字符串操作:从字符串中提取字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆