SERVER-136262Open
Anchored $regex with a {0,n} quantifier on a literal (e.g. /^a{0,2}$/) gets index bounds that exclude zero-repetition matches -- indexed find() silently returns fewer documents
h3. Summary For a left-anchored \{{$regex}}, the planner derives a string prefix and scans only \{{\[prefix, prefix+1)}} in an ascending index. \{{analyze_regex::getRegexPrefixMatch()}} handles \{{*}} and \{{?}} correctly by dropping the preceding character from the prefix. It treats \{{\{}} like \{{+}} instead, ending the prefix but *keeping* the preceding character. \{{\{0,n\}}}, \{{\{0\}}} and \{{\{0,\}}} all make that character optional, so documents that match with zero repetitions fall