title: Delete (unlink) files matching a regex
body: <p>I want to delete several files from a directory, matching a regex. Something like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>// WARNING: not real code
  require('fs').unlink(/script\.\d+\.js$/);
  </code></pre>
  
  <hr>
  
  <p>Since <code>unlink</code> doesn't support regexes, I'm using this instead:</p>
  
  <pre class="lang-js prettyprint-override"><code>var fs = require('fs');
  
  fs.readdir('.', (error, files) =&gt; {
      if (error) throw error;
  
      files.filter(name =&gt; /script\.\d+\.js$/.test(name)).forEach(fs.unlink);
  });
  </code></pre>
  
  <p>which works, but IMO is a little more complex than it should be.</p>
  
  <hr>
  
  <p>Is there a better built-in way to delete files that match a regex (or even just use wildcards)?</p>