title: Regex Directory matching in Groovy
body: <p>As part of Gradle delete task, I would like to delete all tar files beginning with <code>CSW</code> and ending with <code>.tar.gz</code> from a directory.  How can I achieve it with Groovy? </p>
  
  <p>I tried something like below:</p>
  
  <pre><code>delete (file('delivery/').eachDirMatch(~/^CSW$.*.gz/))
  </code></pre>
  
  <p>But it doesn't work. How do I employ the regex in Groovy. As compared to shell it is something like <code>rm -rf CSW*.tar.gz</code></p>