Skip to content

Commit ba87721

Browse files
committed
DOCS-958: Clarification on $regex use of indexes
1 parent fc68802 commit ba87721

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

source/reference/operator/regex.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ $regex
7373
``collection`` that match the case insensitive regular expression
7474
``acme.*corp`` that *don't* match ``acmeblahcorp``.
7575

76-
:operator:`$regex` uses :term:`indexes <index>` only when the
77-
regular expression has an anchor for the beginning (i.e. ``^``)
78-
of a string. Additionally, while ``/^a/``, ``/^a.*/``, and
79-
``/^a.*$/`` are equivalent, they have different performance
80-
characteristics. All of these expressions use an index if an
81-
appropriate index exists; however, ``/^a.*/``, and ``/^a.*$/``
82-
are slower. ``/^a/`` can stop scanning after matching the prefix.
76+
:operator:`$regex` can only use an :term:`index <index>` efficiently
77+
when the regular expression has an anchor for the beginning (i.e. ``^``)
78+
of a string and is a case-sensitive match. Additionally, while
79+
``/^a/``, ``/^a.*/``, and ``/^a.*$/`` match equivalent strings, they
80+
have different performance characteristics. All of these expressions
81+
use an index if an appropriate index exists; however, ``/^a.*/``,
82+
and ``/^a.*$/`` are slower. ``/^a/`` can stop scanning after matching
83+
the prefix.

0 commit comments

Comments
 (0)