text: Q:
  
  MongoDB shell: how to search for collections which match a name or regex
  
  when I use show collections it returns a list of all collections which is pretty long, how can I write a query to return collections matching a pattern. I was hoping for something like db.collections({name:/pattern/}) but couldn't find
  
  A:
  
  You can use db.getCollectionNames() with Array.filter():
  db.getCollectionNames().filter(function (collection) { return /pattern/.test(collection) })
  
  