void RegexMatchExpression::serialize(BSONObjBuilder* out) const {
    BSONObjBuilder regexBuilder(out->subobjStart(path()));
    regexBuilder.append("$regex", _regex);

    if (!_flags.empty()) {
        regexBuilder.append("$options", _flags);
    }

    regexBuilder.doneFast();
}
void RegexMatchExpression::serialize(BSONObjBuilder* out) const {
    BSONObjBuilder regexBuilder(out->subobjStart(path()));
    regexBuilder.append("$regex", _regex);

    if (!_flags.empty()) {
        regexBuilder.append("$options", _flags);
    }

    regexBuilder.doneFast();
}