`pat` can be an extended glob pattern, e.g. `'**/*.less'`
           This code handles negations similarly to node.js' minimatch, i.e.
           a leading `!` will negate the entire pattern.
977218
def glob(self, pat):
        
        r = ""
        negate = int(pat.startswith('!'))
        i = negate

        while i < len(pat):
            if pat[i:i + 3] == '**/':
                r += "(?:.*/)?"
                i += 3
            elif pat[i] == "*":
                r += "[^/]*"
                i += 1
            elif pat[i] == ".":
                r += "[.]"
                i += 1
            elif pat[i] == "?":
                r += "."
                i += 1
            else:
                r += pat[i]
                i += 1
        r += r'\Z(?ms)'
        # print '\n\npat', pat
        # print 'regex:', r
        # print [s.relpath(self).replace('\\', '/') for s in self]
        rx = re.compile(r)

        def match(d):
            m = rx.match(d)
            return not m if negate else m

        return [s for s in self if match(s.relpath(self).replace('\\', '/'))]
1164280
function hasMagic(pattern, options) {
  // Support RegExp as well as glob
  if (pattern instanceof RegExp) {
    return {
      match: function match(str) {
        return pattern.test(str);
      }
    };
  }

  var minimatch = new _minimatch.Minimatch(pattern, options);
  var set = minimatch.set;

  if (set.length > 1) {
    return minimatch;
  }

  for (var j = 0; j < set[0].length; j++) {
    if (typeof set[0][j] !== 'string') {
      return minimatch;
    }
  }

  return false;
}
1057102
def is_negative(pattern, flags):
    """"""

    if flags & MINUSNEGATE:
        return flags & NEGATE and pattern[0:1] in MINUS_NEGATIVE_SYM
    else:
        return flags & NEGATE and pattern[0:1] in NEGATIVE_SYM
1085031
def extend(self, patterns):
        """"""
        assert patterns is not None
        if isinstance(patterns, Pattern):
            self.append(patterns)
            return

        if isinstance(patterns, PatternSet):
            patterns = patterns.patterns

        assert all(isinstance(pat, Pattern) for pat in patterns)
        self.patterns.extend(patterns)
        self._all_files = None
31447
static boolean matchPath(String[] tokenizedPattern, String[] strDirs, boolean isCaseSensitive) {
        int patIdxStart = 0;
        int patIdxEnd = tokenizedPattern.length - 1;
        int strIdxStart = 0;
        int strIdxEnd = strDirs.length - 1;

        // up to first '**'
        while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
            String patDir = tokenizedPattern[patIdxStart];
            if (patDir.equals(DEEP_TREE_MATCH)) {
                break;
            }
            if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) {
                return false;
            }
            patIdxStart++;
            strIdxStart++;
        }
        if (strIdxStart > strIdxEnd) {
            // String is exhausted
            for (int i = patIdxStart; i <= patIdxEnd; i++) {
                if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) {
                    return false;
                }
            }
            return true;
        } else {
            if (patIdxStart > patIdxEnd) {
                // String not exhausted, but pattern is. Failure.
                return false;
            }
        }

        // up to last '**'
        while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
            String patDir = tokenizedPattern[patIdxEnd];
            if (patDir.equals(DEEP_TREE_MATCH)) {
                break;
            }
            if (!match(patDir, strDirs[strIdxEnd], isCaseSensitive)) {
                return false;
            }
            patIdxEnd--;
            strIdxEnd--;
        }
        if (strIdxStart > strIdxEnd) {
            // String is exhausted
            for (int i = patIdxStart; i <= patIdxEnd; i++) {
                if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) {
                    return false;
                }
            }
            return true;
        }

        while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
            int patIdxTmp = -1;
            for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
                if (tokenizedPattern[i].equals(DEEP_TREE_MATCH)) {
                    patIdxTmp = i;
                    break;
                }
            }
            if (patIdxTmp == patIdxStart + 1) {
                // '**/**' situation, so skip one
                patIdxStart++;
                continue;
            }
            // Find the pattern between padIdxStart & padIdxTmp in str between
            // strIdxStart & strIdxEnd
            int patLength = (patIdxTmp - patIdxStart - 1);
            int strLength = (strIdxEnd - strIdxStart + 1);
            int foundIdx = -1;
            strLoop:
            for (int i = 0; i <= strLength - patLength; i++) {
                for (int j = 0; j < patLength; j++) {
                    String subPat = tokenizedPattern[patIdxStart + j + 1];
                    String subStr = strDirs[strIdxStart + i + j];
                    if (!match(subPat, subStr, isCaseSensitive)) {
                        continue strLoop;
                    }
                }

                foundIdx = strIdxStart + i;
                break;
            }

            if (foundIdx == -1) {
                return false;
            }

            patIdxStart = patIdxTmp;
            strIdxStart = foundIdx + patLength;
        }

        for (int i = patIdxStart; i <= patIdxEnd; i++) {
            if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) {
                return false;
            }
        }

        return true;
    }
31202
function extensionMatches (filename) {
		var extname = path.extname(filename);
		if (extname) {
			return extname === extension;
		}
		return true;
	}
180658
def excluded?(filename)
      exclude.each do |f|
        f += '**/*' if f.end_with? '/'
        return true if File.fnmatch(f, filename, File::FNM_EXTGLOB | File::FNM_PATHNAME)
      end
      false
    end
992319
function (op, args) {
            var likeOps = ["~", "~*", "LIKE", "ILIKE"];
            var notLikeOps = ["!~", "!~*", "NOT LIKE", "NOT ILIKE"];
            var regExpOps = ["~", "!~", "~*", "!~*"];
            var binaryOps = ["~", "!~", "LIKE", "NOT LIKE"];
            if (likeOps.indexOf(op) !== -1 || notLikeOps.indexOf(op) !== -1) {
                return format("(%s%s %s%s %s)", this.literal(args[0]), notLikeOps.indexOf(op) !== -1 ? " NOT" : "",
                    regExpOps.indexOf(op) !== -1 ? "REGEXP" : "LIKE", binaryOps.indexOf(op) !== -1 ? " BINARY" : "",
                    this.literal(args[1]));
            } else if (op === "||") {
                if (args.length > 1) {
                    return format("CONCAT(%s)", args.map(this.literal, this).join(", "));
                } else {
                    return this.literal(args[0]);
                }
            } else if (op === "B~") {
                return format("CAST(~%s AS SIGNED INTEGER)", this.literal(args[0]));
            } else {
                return this._super(arguments);
            }
        }
37075
function normalize(p) {
    var isAbsolutePath = isAbsolute(p);
    var trailingSlash = p && p[p.length - 1] === '/';

    p = normalizeArray(p.split('/'), !isAbsolutePath).join('/');

    if (!p && !isAbsolutePath) {
      p += '.';
    }
    if (p && trailingSlash) {
      p += '/';
    }
    return (isAbsolutePath ? '/' : '') + p;
  }
575524
static private boolean hasMatch(String path, List<String> patterns) {
        for (String p : patterns) {
            // Exact match
            if (p.equals(path)) {
                return true;
            }
            // Single dot the end matches this package and all its subpackages.
            if (p.endsWith(".*")) {
                // Remove the wildcard
                String patprefix = p.substring(0,p.length()-2);
                // Does the path start with the pattern prefix?
                if (path.startsWith(patprefix)) {
                    // If the path has the same length as the pattern prefix, then it is a match.
                    // If the path is longer, then make sure that
                    // the next part of the path starts with a dot (.) to prevent
                    // wildcard matching in the middle of a package name.
                    if (path.length()==patprefix.length() || path.charAt(patprefix.length())=='.') {
                        return true;
                    }
                }
            }
        }
        return false;
    }
1336416
private void preprocess(IoBuffer pat) {
    this.b = new int[256];
    this.lim = 0;
    for (int i = 0; i < 256; i++) {
      this.b[i] = ~0;

    }
    for (int i = 0, j = 1; i < this.patternLen; i++, j <<= 1) {
      this.b[ByteBufferUtils.uByte(pat.get(i))] &= ~j;
      this.lim |= j;
    }
    this.lim = ~(this.lim >> 1);

  }
820033
function(str, pattern)
	{
		// LATER: Check is this can be done with a regular expression
		var postfix = '';
		
		while (str.length > 0 && str.charAt(str.length - 1) == '\n')
		{
			str = str.substring(0, str.length - 1);
			postfix += pattern;
		}
		
		return str + postfix;
	}
864136
function(fs, ourGlob, negatives, opt) {

    // remove path relativity to make globs make sense
    ourGlob = resolveGlob(fs, ourGlob, opt);
    var ourOpt = extend({}, opt);
    delete ourOpt.root;

    // create globbing stuff
    var globber = new glob.Glob(fs, ourGlob, ourOpt);
    // extract base path from glob
    var basePath = opt.base || glob2base(globber);

    // create stream and map events from globber to it
    var stream = through2.obj(negatives.length ? filterNegatives : undefined);

    var found = false;

    globber.on('error', stream.emit.bind(stream, 'error'));
    globber.once('end', function(){
      if (opt.allowEmpty !== true && !found && globIsSingular(globber)) {
        stream.emit('error', new Error('File not found with singular glob'));
      }

      stream.end();
    });
    globber.on('match', function(filename) {
      found = true;

      stream.write({
        cwd: opt.cwd,
        base: basePath,
        path: fs.resolve(opt.cwd, filename)
      });
    });

    return stream;

    function filterNegatives(filename, enc, cb) {
      var matcha = isMatch.bind(null, filename);
      if (negatives.every(matcha)) {
        cb(null, filename); // pass
      } else {
        cb(); // ignore
      }
    }
  }
218646
private boolean matchPostagRegexp(AnalyzedTokenReadings aToken, Pattern pattern) {
    for (AnalyzedToken analyzedToken : aToken) {
      String posTag = analyzedToken.getPOSTag();
      if (posTag == null) {
        posTag = "UNKNOWN";
      }
      final Matcher m = pattern.matcher(posTag);
      if (m.matches()) {
        return true;
      }
    }
    return false;
  }
301068
function matches (path) {
      if (type(ignores) === TYPES.STRING) {
        return path.search(ignores) > -1;
      } else if (type(ignores) === TYPES.REGEXP) {
        return ignores.test(path);
      } else {
        return ignores.some(function (ignore) {
          return type(ignore) === TYPES.STRING ? (path.search(ignore) > -1) : ignore.test(path);
        });
      }
    }
812909
function _Glob (pattern, options, callback, shouldIgnore) {
  // We don't put this thing to argument `options` to avoid
  // further problems, such as `options` validation.

  // Use `Symbol` as much as possible to avoid confliction.
  this[IGNORE] = shouldIgnore
  Glob.call(this, pattern, options, callback)
}
488934
def check_path_matches_patterns(path, patterns):
    '''  '''
    path = os.path.abspath(path)
    for patt in patterns:
        if isinstance(patt, six.string_types):
            if path == patt:
                return True
        elif patt.search(path):
            return True
    return False