code: def _translate_pattern(self, pattern, anchor=True, prefix=None,
                             is_regex=False):
          
          if is_regex:
              if isinstance(pattern, str):
                  return re.compile(pattern)
              else:
                  return pattern
  
          if pattern:
              pattern_re = self._glob_to_re(pattern)
          else:
              pattern_re = ''
  
          base = re.escape(os.path.join(self.base, ''))
          if prefix is not None:
              # ditch end of pattern character
              empty_pattern = self._glob_to_re('')
              prefix_re = self._glob_to_re(prefix)[:-len(empty_pattern)]
              sep = os.sep
              if os.sep == '\\':
                  sep = r'\\'
              pattern_re = '^' + base + sep.join((prefix_re,
                                                  '.*' + pattern_re))
          else:                               # no prefix -- respect anchor flag
              if anchor:
                  pattern_re = '^' + base + pattern_re
  
          return re.compile(pattern_re)
docs: Translate a shell-like wildcard pattern to a compiled regular
          expression.
  
          Return the compiled regex.  If 'is_regex' true,
          then 'pattern' is directly compiled to a regex (if it's a string)
          or just returned as-is (assumes it's a regex object).