Lieven Cardoen
Lieven Cardoen

Reputation: 25959

Is there a way to exclude certain files in a fileset using containsregexp?

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?

Upvotes: 2

Views: 2771

Answers (2)

martin clayton
martin clayton

Reputation: 78115

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>

Upvotes: 3

sampson-chen
sampson-chen

Reputation: 47267

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

Here are some related discussion on inverted regex matching:

Upvotes: 0

Related Questions