title: Dynamically build query with regex in PyMongo
body: <p>I want to query different fields on MongoDB from Python, like in an advanced search.</p>
  
  <p>Keeping the example simple with just one field, if I query <code>{'Title': /my string/}</code> manually on Mongo I get the expected results.</p>
  
  <p>On Python I am doing the following:</p>
  
  <pre><code>query = {}
  args = request.form
  for arg in args:
    key = "{0}".format(arg)
    if args[arg] != "":
      query[key] = "/" + args[arg].lower() + "/"
  </code></pre>
  
  <p>However, the query is like this (note the quotes):</p>
  
  <pre><code>{'Title': '/my string/'}
  </code></pre>
  
  <p>So I don't get any results. How can I implement the right query?</p>