簡體   English   中英

在Ant replaceregexp任務中匹配多個模式

[英]Matching multiple pattern in Ant replaceregexp task

我的Ant構建腳本中有一個任務,用於向jsp文件中的所有<script>標記的src屬性添加參數。

       <replaceregexp flags="gi">               
            <fileset dir="${build.web.dir}/WEB-INF/jsp" >   
                <filename name="*.jsp"/>
            </fileset>                  
            <regexp pattern=".js&quot;>"/>
            <substitution expression=".js?param=${pValue}&quot;>"/>         
        </replaceregexp>

我想將此擴展到所有href<link rel="stylesheet">標記的所有href屬性。 當我嘗試添加另一個<regexp>作為

<regexp pattern=".css&quot;>"/>
    <substitution expression=".css?param=${pValue}&quot;>"/>

在同一<replaceregexp> ,我得到錯誤Only one regular expression is allowed. 不使用多個<replaceregexp>塊怎么辦?

您可以在一個表達式中執行此操作:

  <regexp pattern=".(js|css)&quot;>"/>
    <substitution expression=".\1?param=${pValue}&quot;>"/>         

它與捕獲組中的js或css匹配,並在替換中使用捕獲的值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM