code: def namespace_to_regex(namespace):
      
      db_name, coll_name = namespace.split(".", 1)
      # A database name cannot contain a '.' character
      db_regex = re.escape(db_name).replace(r"\*", "([^.]*)")
      # But a collection name can.
      coll_regex = re.escape(coll_name).replace(r"\*", "(.*)")
      return re.compile(r"\A" + db_regex + r"\." + coll_regex + r"\Z")
docs: Create a RegexObject from a wildcard namespace.