There is an inbuilt task given in ant library called 'replaceregexp'. This task is used to check about a specific pattern i.e. a regular expression and replace them with a different pattern in a single file or set of files.
Replace in a set of files
<replaceregexp match="test" replace="replacedTest" flags="gm" byline="false">The above task will look at all the files ending with extension 'txt' in the source directory given as 'sf.srcdir' in the properties file. In all those files, it tries to find the pattern 'test' and replaces with pattern 'replacedTest'
<fileset dir="${sf.srcdir}" includes="*.txt" />
</replaceregexp>