Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions source/reference/operator/regex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ $regex
``collection`` that match the case insensitive regular expression
``acme.*corp`` that *don't* match ``acmeblahcorp``.

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