2011-08-19 10 views
8

ho bersaglio formica che richiama compito replaceregexpUscita nuova riga char in regexp in Java o 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 

output desiderato è

first operation on A1 
second operation on A1 
first operation on A2 
second operation on A2 

Cosa inserire come nuova linea char per produrre l'output desiderato nel parametro ant replaceregexp?

replace="first operation on \1 %NEW_LINE% second operation on \1" 

risposta

16

le seguenti opere per me:

<replaceregexp file="test.txt" 
       match="(.*)" 
       replace="first operation on \1${line.separator}second operation on \1" 
       byline="true"/> 
+0

Wow, Thaks!))) – popalka