我有调用replaceregexp任务的ant目标
<target name="regexp.replace">
<replaceregexp file="${file.temp}"
match="(.*)"
replace="first operation on \1 second operation on \1"
byline="true"/>
</target>
file.temp是
A1
A2
期望的输出是
first operation on A1
second operation on A1
first operation on A2
second operation on A2
要在ant replaceregexp参数中插入新行char以生成所需输出的内容?
replace="first operation on \1 %NEW_LINE% second operation on \1"
答案 0 :(得分:16)
以下适用于我:
<replaceregexp file="test.txt"
match="(.*)"
replace="first operation on \1${line.separator}second operation on \1"
byline="true"/>