简体   繁体   English

如何使用 Ant 检查文件是否包含字符串 a 或字符串 b

[英]How to check with Ant if files contain a string a OR a string b

I'm looking for a way to make this code snippet work but with one of the three contains being true.我正在寻找一种方法来使这个代码片段工作,但三个包含之一是真实的。 So OR instead of AND.所以 OR 而不是 AND。

<condition property="warningFilesFound">
  <resourcecount when="greater" count="0">
    <fileset id="warnings-fileset-id" dir="${target.dir}/xref" includes="**/*.warnings">
      <contains text="requires &#34;CHARACTER&#34;,&#34;RAW&#34; or &#34;COLUMN&#34; for double-byte or multi-byte(UTF8) languages. (3619)"/>
      <contains text="requires &#34;CHARACTER&#34; or &#34;RAW&#34; for double-byte languages. (2363)"/>
      <contains text="requires &#34;CHARACTER&#34;, &#34;RAW&#34;, &#34;COLUMN&#34; or &#34;FIXED&#34; for double-byte or multi-byte(UTF8) languages. (3623)"/>
    </fileset>
  </resourcecount>
</condition>

Only one of the three contains should be true.三个包含中只有一个应该是真的。 In this code snippet all three contains must be true.在此代码片段中,所有三个包含都必须为真。 Regular expression?正则表达式?

You should be able to wrap an <or> selector round the contain elements, something like this:您应该能够将<or>选择器包裹在包含元素周围,如下所示:

<fileset id="warnings-fileset-id" dir="${target.dir}/xref" includes="**/*.warnings">
  <or>
    <contains text="requires &#34;CHARACTER&#34;,&#34;RAW&#34; or &#34;COLUMN&#34; for double-byte or multi-byte(UTF8) languages. (3619)"/>
    <contains text="requires &#34;CHARACTER&#34; or &#34;RAW&#34; for double-byte languages. (2363)"/>
    <contains text="requires &#34;CHARACTER&#34;, &#34;RAW&#34;, &#34;COLUMN&#34; or &#34;FIXED&#34; for double-byte or multi-byte(UTF8) languages. (3623)"/>
  </or>
</fileset>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM