title: Delete all the objects in the AWS-S3 bucket that have key with specific pattern?
body: <p>I want to delete all the objects from an s3 bucket that has the key with the certain pattern. My questions??</p>
  
  <ol>
  <li><p>Can I  simply pass regular expression on the key value as illustrated in the code below?</p></li>
  <li><p>One option would be to list all the objects and filter the keys that matches the regular expression and add them all to the deleteObjects method. I find this inefficient. So, any other way around?
  Would be a great help? Thanks in advance...</p></li>
  </ol>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var params = {
    Bucket: 'sample_bucket', 
    Delete: { 
      Objects: [ 
        {
          Key: '/video-044567/g' // here i want something like that
        },
        
      ],
    },
  };
  
  s3.deleteObjects(params, function(err, data) {
    if (err) console.log(err, err.stack); 
    else     console.log(data);           
  });</code></pre>
  </div>
  </div>
  </p>