Regular expressions
There are several considerations that you have to take into account when querying in MongoDB. Let's look at some best practices for using regular expressions, query results, cursors, and deleting documents:
db.books.find({"name": /mongo/})
This is done to search for books in your books
collection that contain the mongo
name. It is the equivalent of an SQL LIKE
query.
Note
MongoDB uses Perl Compatible Regular Expression (PCRE) version 8.42 with UTF-8 support.
While querying, you can use the following options:
Option |
Description |
|
This option queries case insensitivity. |
|
This option only applies to multiline strings with anchors ( |