We attempted this improvement in
SERVER-30986, the fix for which is present in 3.6.0 through 3.6.5 and 4.0.0. Due to a bug in the underlying PCRE library, this fix broke valid regular expressions which rely on some verbs (e.g. the UCP verb for configuring unicode support). See SERVER-34933 for details. This work was subsequently reverted, so recent versions of the 3.6 and 4.0 due not correctly reject invalid regular expressions. SERVER-39693 tracks the work to fix the underlying issue in PCRE. Once SERVER-39693 is done, we can reintroduce parse-time validation of regular expressions in the MatchExpression library. We should also make sure that any new aggregation expressions which evaluate perl-compatible regexes error at parse time if the regex is invalid, but this work is tracked elsewhere.