我的Ant构建脚本中有一项任务,用于向jsp文件中的所有<script>
标记的src
属性添加一个参数。
<replaceregexp flags="gi">
<fileset dir="${build.web.dir}/WEB-INF/jsp" >
<filename name="*.jsp"/>
</fileset>
<regexp pattern=".js">"/>
<substitution expression=".js?param=${pValue}">"/>
</replaceregexp>
我想将其扩展到所有jsp中<link rel="stylesheet">
标记的所有href
属性。当我试图再添加一个<regexp>
作为时
<regexp pattern=".css">"/>
<substitution expression=".css?param=${pValue}">"/>
在同一个<replaceregexp>
中,我出现错误Only one regular expression is allowed.
如何在不使用多个<replaceregexp>
块的情况下做到这一点?
您可以在一个表达式中完成此操作:
<regexp pattern=".(js|css)">"/>
<substitution expression=".1?param=${pValue}">"/>
它匹配捕获组中的js或css,并在替换中使用捕获的值。