使用filterchain和replaceregex模式

时间:2015-11-13 23:36:11

标签: regex ant

以下是我尝试通过

解析的示例日志文件
Added Change Sets
Component PS
    9476: Build changes to make for Ant task [Nov 12, 2015 12:02 PM]  
      Work Item 9476: Build changes to make for Ant task
      /PS/build/AntTaskHelper.xml
    9582: Testing for EBF and migration script changes [Nov 12, 2015 12:02 PM]  
      Work Item 9582: Testing for EBF and migration script changes
      /PS/database/ebf-migration/EBF-RTC-9582.sql
      /PS/database/sif-internal-migration-scripts/RTC-9582.sql
    9583: PKB PKG and Image File testing [Nov 12, 2015 12:02 PM]  
      Work Item 9583: PKB PKG and Image File testing
      /PS/database/src/program-units/RTC-9583-PKG_CDT.pkb
      /templates/Images/RTC-9583-ABAKER.TIF
      /templates/Templates/RTC-9583-A100_1_20090101.xdp

最终我需要结果显示以下内容:

    /database/ebf-migration/EBF-RTC-9582.sql
    /database/sif-internal-migration-scripts/RTC-9582.sql
    /database/src/program-units/RTC-9583-PKG_CDT.pkb
    /templates/Images/RTC-9583-ABAKER.TIF
    /templates/Templates/RTC-9583-A100_1_20090101.xdp

我的正则表达式在使用示例reg exp测试器进行测试时非常有效,但在构建中运行时并不是我需要的。

这是我的目标

<target name="Parse">
    <loadfile property="textFile" srcfile="${deployDir}\buildChanges1.txt">
    <filterchain>
           <linecontainsregexp>
               <regexp pattern="((/database/(ebf-migration|sif-internal-migration-scripts/|src/program-units/))|(/templates/)).*" />
            </linecontainsregexp>
                <replaceregex pattern="((/database/(ebf-migration|sif-internal-migration-scripts/|src/program-units/))|(/templates/)).*" replace="\0"/>
    </filterchain>
    </loadfile>
    <echo message= "value based on regex =${textFile}"/>
</target>  

这是构建的输出。

Parse:
     [echo] value based on regex =      /PS/database/ebf-migration/EBF-RTC-9582.sql
     [echo]       /PS/database/sif-internal-migration-scripts/RTC-9582.sql
     [echo]       /PS/database/src/program-units/RTC-9583-PKG_CDT.pkb
     [echo]       /templates/Images/RTC-9583-ABAKER.TIF
     [echo]       /templates/Templates/RTC-9583-A100_1_20090101.xdp

非常感谢任何有关让它运行的帮助。

0 个答案:

没有答案