code: def validate(self):
          
          from pyrocore.torrent import formatting
  
          super(PatternFilter, self).validate()
          self._value = self._value.lower()
          self._template = None
          self._is_regex = self._value.startswith('/') and self._value.endswith('/')
          if self._is_regex:
              self._matcher = re.compile(self._value[1:-1]).search
          elif self._value.startswith('{{') or self._value.endswith('}}'):
              def _template_globber(val, item):
                  """Helper."""
                  pattern = formatting.format_item(self._template, item).replace('[', '[[]')
                  ##print('!!!', val, '~~~', pattern, '???')
                  return fnmatch.fnmatchcase(val, pattern.lower())
  
              self._template = formatting.preparse(self._value)
              self._matcher = _template_globber
          else:
              self._matcher = lambda val, _: fnmatch.fnmatchcase(val, self._value)
docs: Validate filter condition (template method).