@@ -42,14 +42,29 @@ Compatibility
4242Syntax
4343------
4444
45- To use :query:` $regex`, use one of the following syntaxes:
45+ To use `` $regex` `, use one of the following syntaxes:
4646
4747.. code-block:: javascript
4848
4949 { <field>: { $regex: /pattern/, $options: '<options>' } }
50- { <field>: { $regex: ' pattern', $options: ' <options>' } }
50+ { " <field>" : { " $regex": " pattern", " $options": " <options>" } }
5151 { <field>: { $regex: /pattern/<options> } }
5252
53+ .. note::
54+
55+ To use ``$regex`` with :binary:`~bin.mongodump`, you must enclose the query
56+ document in single quotes ('{ ... }') to ensure that it does not interact
57+ with your shell environment.
58+
59+ The query document must be in :ref:`Extended JSON v2
60+ <mongodb-extended-json-v2>` format (either relaxed or canonical/strict mode),
61+ which includes enclosing the field names and operators in quotes. For
62+ example:
63+
64+ .. code-block:: sh
65+
66+ mongodump -d=sample_mflix -c=movies -q='{"year": {"$regex": "20"}}'
67+
5368In MongoDB, you can also use regular expression objects (i.e.
5469``/pattern/``) to specify regular expressions:
5570
@@ -97,7 +112,7 @@ expression.
97112 * - ``x``
98113
99114 - "Extended" capability to ignore all white space characters in
100- the :query:` $regex` pattern unless escaped or included in a
115+ the `` $regex` ` pattern unless escaped or included in a
101116 character class.
102117
103118 Additionally, it ignores characters in-between and including
@@ -122,7 +137,7 @@ expression.
122137
123138.. note::
124139
125- The :query:` $regex` operator does not support the global search
140+ The `` $regex` ` operator does not support the global search
126141 modifier ``g``.
127142
128143Behavior
@@ -144,14 +159,14 @@ only use JavaScript regular expression objects (i.e. ``/pattern/``
144159
145160 { name: { $in: [ /^acme/i, /^ack/ ] } }
146161
147- You *cannot* use :query:` $regex` operator expressions inside an
148- :query:`$in`.
162+ You *cannot* use `` $regex` ` operator expressions inside an
163+ :query:`$in` operator .
149164
150165Implicit ``AND`` Conditions for the Field
151166`````````````````````````````````````````
152167
153168To include a regular expression in a comma-separated list of query
154- conditions for the field, use the :query:` $regex` operator. For example:
169+ conditions for the field, use the `` $regex` ` operator. For example:
155170
156171.. code-block:: javascript
157172
@@ -163,7 +178,7 @@ conditions for the field, use the :query:`$regex` operator. For example:
163178```````````````````````
164179
165180To use either the ``x`` option or ``s`` options, you must use the
166- :query:` $regex` operator expression *with* the :query:`$options`
181+ `` $regex` ` operator expression *with* the :query:`$options`
167182operator. For example, to specify the ``i`` and the ``s`` options, you
168183must use :query:`$options` for both:
169184
@@ -176,7 +191,7 @@ PCRE vs JavaScript
176191``````````````````
177192
178193To use PCRE supported features in a regular expression that aren't
179- supported in JavaScript, you must use the :query:` $regex` operator and
194+ supported in JavaScript, you must use the `` $regex` ` operator and
180195specify the regular expression as a string.
181196
182197To match case-insensitive strings:
@@ -195,7 +210,7 @@ These strings match the example regular expression:
195210- ``"acme"``
196211- ``"Acme"``
197212
198- The following example uses the :query:` $regex` operator to find ``name``
213+ The following example uses the `` $regex` ` operator to find ``name``
199214field strings that match the regular expression ``"(?i)a(?-i)cme"``:
200215
201216.. code-block:: javascript
@@ -216,7 +231,7 @@ operation on both:
216231
217232 db.inventory.find( { item: { $not: /^p.*/ } } )
218233
219- - :query:` $regex` operator expressions
234+ - `` $regex` ` operator expressions
220235
221236 For example:
222237
@@ -361,7 +376,7 @@ Without the ``m`` option, the example output is:
361376 { _id: 104, sku: 'Abc789', description: 'SKU starts with A' }
362377 ]
363378
364- If the :query:` $regex` pattern does not contain an anchor, the pattern
379+ If the `` $regex` ` pattern does not contain an anchor, the pattern
365380matches against the string as a whole, as in the following example:
366381
367382.. code-block:: javascript
0 commit comments