code: def filter( names, pat ):
      
      import os, posixpath
  
      result = [ ]
      pat = os.path.normcase( pat )
      if not pat in _cache:
          res = translate( pat )
          if len( _cache ) >= _MAXCACHE:
              _cache.clear( )
          _cache[ pat ] = re.compile( res )
      match = _cache[ pat ].match
      if os.path is posixpath:
          # normcase on posix is NOP. Optimize it away from the loop.
          for name in names:
              if match( name ):
                  result.append( name )
      else:
          for name in names:
              if match( os.path.normcase( name ) ):
                  result.append( name )
      return result
docs: Return the subset of the list NAMES that match PAT