Ant 的 replace 操作


replace 可以替換某個文件中的字符串。

<?xml version="1.0" encoding="UTF-8"?>
<project name="testCondition">
    <replace file="testfile1.txt"    token="hello"     value="world"/>
</project>

結果就把 testfile1.txt 中的 "hello" 替換成了 "world".

也可以批量處理:

<?xml version="1.0" encoding="UTF-8"?>
<project name="testCondition">
    <replace dir="." includes="*.txt" encoding="UTF-8">
        <replacefilter token="this" value="that"/>
        <replacefilter token="o" value="00"/>
    </replace>
</project>

就把當前文件夾下面所有 txt 文件按照指定的 filter 替換了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM