【问题标题】:Question related to find/replace using propertyregex与使用 propertyregex 查找/替换相关的问题
【发布时间】:2010-12-05 11:07:43
【问题描述】:

在我的 ant 构建文件中,我有一个包含版本的属性“版本”。前任。 2.5.17.230

现在,我正在使用 ant-contrib 的 propertyregex 来替换所有的 '.' (点)带有下划线的字符。我写的声明如下:

<propertyregex property="Version" input="${Version}" regexp="." replace="_" global="true" />

但是,它不起作用。我什至徒劳地尝试了这些: regexp="\."regexp="[.]"

有人可以帮忙吗?

谢谢

【问题讨论】:

    标签: ant ant-contrib


    【解决方案1】:

    PropertyRegexdocumentation 声明除非override 属性设置为true,否则任务不会覆盖已设置的属性值。而且由于您试图覆盖 Version 属性,因此您的示例将无济于事。

    【讨论】:

      【解决方案2】:

      知道了!我传递了与输入相同的变量。我使用另一个变量“Version2”从propertyregex 获取结果。应该是这样的:

      <propertyregex property="Version2" input="${Version}" regexp="\." replace="_" global="true" />

      干杯!

      【讨论】:

        猜你喜欢
        • 2011-02-19
        • 1970-01-01
        • 2011-02-11
        • 2020-12-15
        • 2011-03-31
        • 1970-01-01
        • 2015-04-15
        • 2013-07-27
        • 2014-04-06
        相关资源
        最近更新 更多