需要Ant脚本来替换字符串

时间:2014-12-21 07:37:59

标签: ant

示例:test.txt

hello:../../Need/script/hello/123/234
hello:../../../../Need/script/hello/123/468
hello:../Need/Script/hello/123/789

需要使用此字符串替换“hello”字词:“:D:/ test / testing / tester /”

输出:test.txt

hello:D:/test/testing/tester/hello/123/234
hello:D:/test/testing/tester/hello/123/468
hello:D:/test/testing/tester/hello/123/789

尝试了类似下面的脚本,但是遇到了java错误。

<replaceregexp file="./test.txt"
               match="hello**hello"
               replace="hello:D:/test/testing/tester/hello"
               byline="true"/>

错误:

D:\Others\anttest\build.xml:7: java.util.regex.PatternSyntaxException: Dangling
meta character '*' near index 6
hello**hello
      ^
        at java.util.regex.Pattern.error(Pattern.java:1924)
        at java.util.regex.Pattern.sequence(Pattern.java:2090)
        at java.util.regex.Pattern.expr(Pattern.java:1964)
        at java.util.regex.Pattern.compile(Pattern.java:1665)
        at java.util.regex.Pattern.<init>(Pattern.java:1337)

0 个答案:

没有答案