'BSON regular expression data.
This class is useful to store and retrieve regular expressions that are
incompatible with Python\'s regular expression dialect.
:Parameters:
- `pattern`: string
- `flags`: (optional) an integer bitmask, or a string of flag
characters like "im" for IGNORECASE and MULTILINE'

def __init__(self, pattern, flags=0):

    if (not isinstance(pattern, (text_type, bytes))):
        raise TypeError(('pattern    must    be    a    string,    not    %s' % type(pattern)))
    self.pattern = pattern
    if isinstance(flags, string_type):
        self.flags = str_flags_to_int(flags)
    elif isinstance(flags, int):
        self.flags = flags
    else:
        raise TypeError(('flags    must    be    a    string    or    int,    not    %s' % type(flags)))
