docs: def register(self, patterns, obj=None, instances=None, **reg_kwargs):
          """Register one object which can be matched/searched by regex.
  
          :param patterns: a list/tuple/set of regex-pattern.
          :param obj: return it while search/match success.
          :param instances: instance list will search/match the patterns.
          :param reg_kwargs: kwargs for re.compile.
          """
          assert obj, "bool(obj) should be True."
          patterns = patterns if isinstance(patterns, (list, tuple, set)) else [patterns]
          instances = instances or []
          instances = (
              instances if isinstance(instances, (list, tuple, set)) else [instances]
          )
          for pattern in patterns:
              pattern_compiled = re.compile(pattern, **reg_kwargs)
              self.container.append((pattern_compiled, obj, instances))
              if self.ensure_mapping:
                  # check all instances to avoid one-to-many instances.
                  self._check_instances()
              else:
                  # no need to check all instances.
                  for instance in instances:
                      assert self.search(instance) == [obj] or self.match(instance) == [
                          obj
                      ], (
                          "instance %s should fit at least one pattern %s"
                          % (instance, pattern)
                      )