I've the next block that begins and finishes 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 produced an ant task that finds everything between your <!--source scripts--><!--end source scripts--> and replaces it with a brand new script file (within this situation min.js), however i have trouble which makes it work.

This is exactly what I have done to date:

<target name="update-source-with-new-compiled-files">
    <replaceregexp match="\&lt;!--source scripts--\&gt;(.*?)\&lt;!--end source scripts--\&gt;" replace="\&lt;script src='min.js'\&gt;\&lt;/script\&gt;" flags="g">
        <fileset dir="${basedir}/../dist" includes="*"/>
    </replaceregexp>
</target>

Just add the s flag for your flags :

<replaceregexp match="\&lt;!--source scripts--\&gt;(.*?)\&lt;!--end source scripts--\&gt;" replace="\&lt;script src='min.js'\&gt;\&lt;/script\&gt;" flags="gs">
        <fileset dir="${basedir}/../dist" includes="*"/>
</replaceregexp>