Home:ALL Converter>How works regex in MongoDB?

How works regex in MongoDB?

Ask Time:2013-06-16T19:36:30         Author:tostao

Json Formatter

I have collection like:

{
"city" : "ACMARE",
"state" : "AL",
"_id" : "001"
}

How aggregate this collection by City using regexp? For example: cities which name starts with letter from D to H? I read this, but it is still not clear how use regexp.

Author:tostao,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/17132886/how-works-regex-in-mongodb
Casimir et Hippolyte :

Try this perhaps:\n\ndb.collection.aggregate(\n { $match: { city : /^[D-H].*/ } } \n);\n",
2013-06-16T11:41:22
yy