(doc)
return Regex(regex['pattern'], regex['options'])
Decode a JSON regex to bson.regex.Regex.
Decode a JSON regex to bson.regex.Regex.
Decode a JSON regex to bson . regex . Regex .
def _parse_canonical_regex(doc):
    """Decode a JSON regex to bson.regex.Regex."""
    regex = doc['$regularExpression']
    if len(doc) != 1:
        raise TypeError('Bad $regularExpression, extra field(s): %s' % (doc,))
    if len(regex) != 2:
        raise TypeError('Bad $regularExpression must include only "pattern"'
                        'and "options" components: %s' % (doc,))
    return Regex(regex['pattern'], regex['options'])
def _parse_canonical_regex ( doc ) : regex = doc [ '$regularExpression' ] if len ( doc ) != 1 : raise TypeError ( 'Bad $regularExpression, extra field(s): %s' % ( doc , ) ) if len ( regex ) != 2 : raise TypeError ( 'Bad $regularExpression must include only "pattern"' 'and "options" components: %s' % ( doc , ) ) return Regex ( regex [ 'pattern' ] , regex [ 'options' ] )