与使用 propertyregex 查找/替换相关的问题

发布于 2024-10-05 18:10:48 字数 393 浏览 0 评论 0原文

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

现在,我使用 ant-contrib 的 propertyregex 来替换所有“.”带下划线的(点)字符。我编写的语句如下:

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

有人可以帮忙吗?

谢谢

In my ant build file, I have a property 'Version' that contains the version. Ex. 2.5.17.230

Now, I am using propertyregex of ant-contrib to replace all '.' (dot) characters with an underscore. I have written the statement as follows:

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

However, it does not work. I have even tried these in vain:
regexp="\." and regexp="[.]"

Can someone please help?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

删除→记忆 2024-10-12 18:10:48

PropertyRegex 文档 指出,除非 < code>override 属性设置为 true,如果已设置,任务将不会覆盖属性值。由于您尝试覆盖 Version 属性,因此您的示例将不会执行任何操作。

The PropertyRegex documentation states that unless the override attribute is set to true, the task will not overwrite the property value if it's already set. And since you're trying to overwrite the Version property, your example will do nothing.

2024-10-12 18:10:48

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

干杯

Got it! I was passing the same variable as input. I used another variable 'Version2' to get the result from propertyregex. Here is what it should have been:

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

Cheers!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文