How to get each substring in a file by Ant -


i have file contains following lines of strings separated "|",

c:\temp\demo\aaa.dat   |    c:\test\input\aaa.dat c:\temp\build\bbb.bat  |    c:\test\java\bbb.bat c:\temp\test\ccc.xml   |    c:\apps\ftp\ccc.xml 

after read each line, hope extract each string separated "|", ie, after 1st line, need both c:\temp\demo\aaa.dat , c:\test\input\aaa.dat; pls how use ant it???

i use following code can each line :

<loadfile property="filelist" srcfile="c:\temp\file1.txt"/> <target name="test" depends="chkinput" description="test">      <for param = "line" list="${filelist}" delimiter="${line.separator}">         <sequential>              <echo>@{line}</echo>         </sequential>      </for>  </target> 

not each substring separated "|", pls how each substring separated "|"?

once have line, can use <propertyregex> separate 2 pieces.

<for param = "line" list="${filelist}" delimiter="${line.separator}">     <sequential>          <echo>@{line}</echo>         <var name="first.part" unset="true"/>         <var name="second.part" unset="true"/>         <propertyregex             property="first.part"             input="@{line}"             regex="^([^\s]*)"             select="\1"/>         <propertyregex             property="second.part"             input="@{line}"             regex="\|\s*([^\s]*).*$"             select="\1"/>    </sequential>  </for> 

note have use either <var/> task unset property (or otherwise, you're not changing property, or new task declare property local <sequential/> entity.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -