1

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
  • 24,339
  • 50
  • 144
  • 235

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
  • 74,574
  • 30
  • 214
  • 196
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
  • 43,283
  • 12
  • 82
  • 80