docs: def _matches(self, entities=None, extensions=None, regex_search=False):
          """
          Checks whether the file matches all of the passed entities and
          extensions.
  
          Args:
              entities (dict): A dictionary of entity names -> regex patterns.
              extensions (str, list): One or more file extensions to allow.
              regex_search (bool): Whether to require exact match (False) or
                  regex search (True) when comparing the query string to each
                  entity.
          Returns:
              True if _all_ entities and extensions match; False otherwise.
          """
          if extensions is not None:
              extensions = map(re.escape, listify(extensions))
              extensions = '(' + '|'.join(extensions) + ')$'
              if re.search(extensions, self.filename) is None:
                  return False
  
          if entities is None:
              return True
  
          for name, val in entities.items():
  
              if (name not in self.entities) ^ (val is None):
                  return False
  
              if val is None:
                  continue
  
              def make_patt(x):
                  patt = str(x)
                  if not regex_search:
                      patt = re.escape(patt)
                  if isinstance(x, (int, float)):
                      # allow for leading zeros if a number was specified
                      # regardless of regex_search
                      patt = '0*' + patt
                  if not regex_search:
                      patt = '^{}$'.format(patt)
                  return patt
  
              ent_patts = [make_patt(x) for x in listify(val)]
              patt = '|'.join(ent_patts)
  
              if re.search(patt, str(self.entities[name])) is None:
                  return False
  
          return True