title: Escaping a square bracket in a MongoDB regex / PCRE
body: <p>I need to query a MongoDB database for documents whose field <code>x</code> starts with <code>[text</code>. I tried the following:
  <code>
  db.collection.find({x:{$regex:/^[text/}})
  </code>
  which fails because <code>[</code> is part of the regex syntax. So I've spent some time trying to find how to escape <code>[</code> from my regex... without any success so far.</p>
  
  <p>Any help appreciated, thanks!</p>