I would like to count documents with a certain amount of characters for one specific field, and I do this by using regex:
total_count = db.collection.count({'field': {'$regex': '^pattern{m,n}$'}})
This fails.
The problem is in the {m,n}
syntax for mongodb/pymongo, because the following gives good results:
total_count = db.collection.count({'field': {'$regex' : '^pattern+'}})
and the expression '/^pattern{m,n}$/'
works smoothly in other applications (tested on: http://www.regexr.com/)
In my case, pattern = [0-9a-zA-Z \W],
but this should not be relevant.