ANT:用文件名本身替换文件中的字符串

发布于 2024-10-04 08:39:28 字数 247 浏览 0 评论 0原文

我遇到的情况是,我需要扫描大量 .xsd 文件,并根据正在检查的当前架构的文件名将一个字符串实例替换为另一个字符串。

例如: 我希望将 file1.xsd 中的字符串:“DataSet”替换为字符串“file1DataSet” 我希望将 file2.xsd 中的字符串:“DataSet”替换为字符串“file2DataSet” 依此类推,直到所有模式都被修改。

我想知道是否有办法在不使用 ant-contrib for 循环的情况下执行此操作。

I have a situation where I need to scan through a large number of .xsd files, and replace an instance of a string with another string based on the file name of the current schema being examined.

For example:
I wish to replace the string: 'DataSet' in file1.xsd with the string 'file1DataSet'
I wish to replace the string: 'DataSet' in file2.xsd with the string 'file2DataSet'
and so on until all schemas have been modified.

I would like to know if there is anyway to do this without using the ant-contrib for loops.

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

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

发布评论

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

评论(1

染年凉城似染瑾 2024-10-11 08:39:28

如果您大致了解如何执行,则可以尝试 任务你有很多模式。 可能能够在不循环的情况下完成此操作。

Ant 并不是一种真正可以循环的编程语言。如果您可以一次完成所有事情,那就太好了,但是一旦您开始真正操作文件,Ant 就会遇到限制。

You could try the <replace> task if you have a generally good idea how many schemas you have. The <replaceRegex> might be able to do it without looping.

Ant isn't really a programming language where you can loop. If you can do everything in one pass, that's great, but once you start really manipulating files, Ant runs into limitations.

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