How to Replace All Occurrences of Carriage Return Using Ant
I am trying to replace all occurrences of a carriage return ("\x0D"
) using a simple ant task, all *.sh
files in the test directory. It does not seem to do the trick.
This is my script; am I doing something wrong? (It seems the global开发者_开发百科 flag, g
, does not help either)
<?xml version='1.0'?>
<project name="myproject" default="cr_remover" basedir=".">
<target name="cr_remover">
<replaceregexp match="\x0D" replace="" flags="g" byline="true">
<fileset dir="."><include name="**/*.sh"/></fileset>
</replaceregexp>
</target>
</project>
This will work:
<replaceregexp match="\x0D" replace="" flags="sg">
May I ask why you are not using FixCRLF task?
<fixcrlf srcdir="." includes="**/*.sh"
eol="lf"
eof="remove"
/>
From the apache replaceregexp man page
<replaceregexp match="\s+" replace=" " flags="g" byline="true">
<fileset dir="${html.dir}" includes="**/*.html"/>
</replaceregexp>
Note that you have
<fileset dir="."><include name="**/*.sh"/></fileset>
I'm not enough of an ant person to know if that is what is causing your problem.
I hope this helps.
- As you receive help, try to give it too, answering questions in your area of expertise
- Read the FAQs
- When you see good Q&A, vote them up by using the gray triangles as the credibility of the system is based on the reputation that users gain by sharing their knowledge. Also remember to accept the answer that better solves your problem, if any, by pressing the checkmark sign
精彩评论