Skip to content

Instantly share code, notes, and snippets.

@davit-khaburdzania
Last active December 13, 2015 20:38
Show Gist options
  • Save davit-khaburdzania/4971620 to your computer and use it in GitHub Desktop.
Save davit-khaburdzania/4971620 to your computer and use it in GitHub Desktop.
mongoDB Notes
## searching with regular expressions
you can use regular expressions while searching for something ex:
db.airports.find(name: {$regex: "[^\s]paris", $options: "i"})
this regex matches every document in airports collections whichs name start with paris
or include whitespace character and then paris. but this will't work as expected because
in strings \ character works as escape character so we need to excape it too
this will work as expected:
db.airports.find(name: {$regex: "[^\\s]paris", $options: "i"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment