2

Is there a way in ant to exclude certain files from a fileset using a regular expression?

containsregexp can be used to include files, but how do I exclude files matching a regex?

Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244

2 Answers2

3

You're probably looking for the <not> selector container. The Ant docs example

<fileset dir="." includes="*.txt">
    <containsregexp expression="[4-6]\.[0-9]"/>
</fileset>

could be negated thus:

<fileset dir="." includes="*.txt">
    <not>
        <containsregexp expression="[4-6]\.[0-9]"/>
    </not>
</fileset>
martin clayton
  • 76,436
  • 32
  • 213
  • 198
0

In general you can use ! to prefix a regex pattern to invert the matching.

Here are some related discussion on inverted regex matching:

Community
  • 1
  • 1
sampson-chen
  • 45,805
  • 12
  • 84
  • 81