find replace text in file with Phing

milan picture milan · Feb 5, 2011 · Viewed 9.9k times · Source

Does anyone know how to find and replace text inside a file with Phing?

Answer

acme picture acme · Nov 8, 2011

If you don't want to copy files and just replace a string in the current folder where your files reside, do a reflexive task:

<reflexive>
    <fileset dir=".">
        <include pattern="*.js" />
    </fileset>
    <filterchain>
        <replaceregexp>
            <regexp pattern="SEARCH" replace="REPLACEMENT"/>
        </replaceregexp>
    </filterchain>
</reflexive>