Reputation: 1097
I have a task in my Ant build script for adding a parameter to the src
attribute to all <script>
tags in jsp files.
<replaceregexp flags="gi">
<fileset dir="${build.web.dir}/WEB-INF/jsp" >
<filename name="*.jsp"/>
</fileset>
<regexp pattern=".js">"/>
<substitution expression=".js?param=${pValue}">"/>
</replaceregexp>
I want to extend this to all href
attributes of <link rel="stylesheet">
tags in all jsps. When I tried to add one more <regexp>
as
<regexp pattern=".css">"/>
<substitution expression=".css?param=${pValue}">"/>
in the same <replaceregexp>
, I am getting error
Only one regular expression is allowed.
How can I do this without using multiple <replaceregexp>
blocks?
Upvotes: 0
Views: 3988
Reputation: 111142
You can do this in one expression:
<regexp pattern=".(js|css)">"/>
<substitution expression=".\1?param=${pValue}">"/>
Which matches js or css in a capturing group and uses the captured value in the substitution.
Upvotes: 2