Ant replaceregexp task - Match and replace HTML comments block
13,725
Just add the s flag to your flags :
<replaceregexp match="\<!--source scripts--\>(.*?)\<!--end source scripts--\>" replace="\<script src='min.js'\>\</script\>" flags="gs">
<fileset dir="${basedir}/../dist" includes="*"/>
</replaceregexp>
Author by
72lions
My name is Thodoris Tsiridis and I am from Greece. In February 2011 I moved to Stockholm, Sweden to work at Fi, where I had the opportunity to work with some really GREAT and TALENTED people. In January 2012 I joined Spotify and I'll be part of the team that makes your life a little bit better through music!
Updated on July 06, 2022Comments
-
72lions almost 2 years
I have the following block that starts and ends with HTML comments:
<!--source scripts--> <script type="text/javascript" src="/assets/js/namespaces.js"></script> <script type="text/javascript" src="/assets/js/main.js"></script> <script type="text/javascript" src="/assets/js/header.js"></script> <script type="text/javascript" src="/assets/js/headerPremiumForm.js"></script> <script type="text/javascript" src="/assets/js/bootstrap.js"></script> <!--end source scripts-->
I created an ant task that finds everything between the
<!--source scripts--><!--end source scripts-->
and replaces it with a new script file (in this case min.js), but I have trouble making it work.This is what I've done so far:
<target name="update-source-with-new-compiled-files"> <replaceregexp match="\<!--source scripts--\>(.*?)\<!--end source scripts--\>" replace="\<script src='min.js'\>\</script\>" flags="g"> <fileset dir="${basedir}/../dist" includes="*"/> </replaceregexp> </target>