"glob" (aka "wildmat") patterns, e.g. "glob:one,two,*"
508888
function(globString) {
        this.regexp = new RegExp(PatternMatcher.regexpFromGlob(globString));
        this.matches = function(actual) {
            return this.regexp.test(actual);
        };
    }
954097
function getPatternId(pattern) {
  var inconsiderate = pattern.inconsiderate
  var phrases = {}
  var result = []
  var phrase
  var category

  for (phrase in inconsiderate) {
    category = inconsiderate[phrase]

    if (!phrases[category] || phrases[category].length > phrase.length) {
      phrases[category] = phrase
    }
  }

  for (phrase in phrases) {
    result.push(phrases[phrase].replace(/[\s.]+/g, '-'))
  }

  return result.sort().join('-')
}
379105
def pattern(name, pattern):
  
  pattern.setName(name)
  astracing.maybe_trace(pattern)
  return pattern
693174
function glob(str, prefix) {
        var globArr = str.split(',');
        var group = [];
        var s_reg;
        globArr.forEach(function(g) {
            if (g.length > 0) {
                s_reg = fis.util.glob(g, undefined, {nocase: true}).toString();
                //replace
                // '/^' => ''
                // '$/i' => ''
                s_reg = s_reg.substr(2, s_reg.length - 5);
                group.push(s_reg);
            }
        });
        prefix = prefix || '';
        if (prefix) {
            s_reg = fis.util.glob(prefix, undefined, {nocase: true}).toString();
            // '/^' => '', '%/i' => ''
            prefix = s_reg.substr(2, s_reg.length - 5);
        }
        return new RegExp('^'+ prefix + '(' + group.join('|') + ')$', 'i');
    }
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)
}
1216812
def glob_compile(pat):
    

    i, n = 0, len(pat)
    res = ''
    while i < n:
        c = pat[i]
        i = i + 1
        if c == '/' and len(pat) > (i + 2) and pat[i:(i + 3)] == '**/':
            # Special-case for "any number of sub-directories" operator since
            # may also expand to no entries:
            #  Otherwise `a/**/b` would expand to `a[/].*[/]b` which wouldn't
            #  match the immediate sub-directories of `a`, like `a/b`.
            i = i + 3
            res = res + '[/]([^/]*[/])*'
        elif c == '*':
            if len(pat) > i and pat[i] == '*':
                i = i + 1
                res = res + '.*'
            else:
                res = res + '[^/]*'
        elif c == '?':
            res = res + '[^/]'
        elif c == '[':
            j = i
            if j < n and pat[j] == '!':
                j = j + 1
            if j < n and pat[j] == ']':
                j = j + 1
            while j < n and pat[j] != ']':
                j = j + 1
            if j >= n:
                res = res + '\\['
            else:
                stuff = pat[i:j].replace('\\', '\\\\')
                i = j + 1
                if stuff[0] == '!':
                    stuff = '^' + stuff[1:]
                elif stuff[0] == '^':
                    stuff = '\\' + stuff
                res = '%s[%s]' % (res, stuff)
        else:
            res = res + re.escape(c)
    return re.compile('^' + res + '\Z(?ms)' + '$')
76702
function wildCardMatch(text, pattern){
	var cards = pattern.split("*");
	if (!pattern.startsWith("*") && !text.startsWith(cards[0])) { //$NON-NLS-1$
		return false;
	}
	if (!pattern.endsWith("*") && !text.endsWith(cards[cards.length - 1])) { //$NON-NLS-1$
		return false;
	}
	return !cards.some(function(card){
		var idx = text.indexOf(card);
		if (idx === -1){
			return true;
		}
		text = text.substring(idx + card.length);
	});
}
1217483
def match_patterns(pathname, patterns):
    """"""
    for pattern in patterns:
        if fnmatch(pathname, pattern):
            return True
    return False
975275
def pattern( list, opts={} )
      return '(?!)' unless list.any?
      return bud(opts).pattern list unless opts.empty?
      list = list.compact.map(&:to_s).select{ |s| s.length > 0 }
      list.map!(&:strip).select!{ |s| s.length > 0 } if strip
      list.map!{ |s| s.gsub %r/\s++/, ' ' } if normalize_whitespace
      return nil if list.empty?
      specializer = Special.new self, @symbols, list
      list = specializer.normalize

      root = tree list, specializer
      root.root = true
      root.flatten
      rx = root.convert
      if m = modifiers
        rx = "(?#{m}:#{rx})"
        grouped = true
      end
      if name
        rx = "(?<#{name}>#{rx})"
        grouped = true
      end
      return rx if grouped && backtracking
      if atomic && !root.atomic?
        wrap rx
      else
        rx
      end
    end
1283095
def filter_wildcard(names, pattern):
    
    return tuple(name for name in names
                 if fnmatch.fnmatch(name, pattern))
1215903
private function patternHasMatch($globPattern)
    {
        if (substr(trim($globPattern), 0, 1) === '/') {
            $globPattern = trim(substr($globPattern, 1));
        } elseif (substr(trim($globPattern), -1) === '/') {
            $globPattern = trim(substr($globPattern, 0, -1));
        } else {
            $globPattern = '{' . trim($globPattern) . '}*';
        }

        $initialWorkingDirectory = (string) getcwd();
        chdir($this->directory);

        $matches = glob($globPattern, GLOB_BRACE);

        chdir($initialWorkingDirectory);

        return is_array($matches) && count($matches) > 0;
    }
818470
function TilingPattern(IR, color, ctx, objs, commonObjs, baseTransform) {
    this.operatorList = IR[2];
    this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
    this.bbox = IR[4];
    this.xstep = IR[5];
    this.ystep = IR[6];
    this.paintType = IR[7];
    this.tilingType = IR[8];
    this.color = color;
    this.objs = objs;
    this.commonObjs = commonObjs;
    this.baseTransform = baseTransform;
    this.type = 'Pattern';
    this.ctx = ctx;
  }
1155785
def make_pattern_list(patterns):
    """"""
    pattstrs = []
    for desc, patts in patterns:
        # ";," not allowed in descriptions or patterns
        patts = [p.replace(";", "").replace(",", "") for p in patts]
        desc = desc.replace(";", "").replace(",", "")
        pattstrs.append("%s=%s" % (desc, ','.join(patts)))
    return ";".join(pattstrs)
473528
function globs(sourcePath, ignore, commands, done) {
  var expression = /\$g\[(.+?)\]/g;
  var result = [];
  each(commands, function(command, next) {
    var map = {};
    var match;
    var matches = [];
    while ((match = expression.exec(command))) matches.push(match);
    each(matches, function(patternMatch, next) {
      find(patternMatch[1], sourcePath, ignore, function(err, relativePaths) {
        if (err) return next(err);
        map[patternMatch[1]] = relativePaths;
        next();
      });
    }, function(err) {
      if (err) return next(err);
      result.push(command.replace(expression, function(match, matchKey) {
        return map[matchKey].join(' ');
      }));
      next();
    });
  }, function(err) {
    if (err) return done(err);
    done(undefined, result);
  });
}
397176
def _compile_wildcard(self, pattern, pathname=False):
        """"""

        patterns = None
        flags = self.flags
        if pathname:
            flags |= _wcparse.PATHNAME
        if pattern:
            patterns = _wcparse.WcSplit(pattern, flags=flags).split()

        return _wcparse.compile(patterns, flags) if patterns else patterns
658640
function walk(patterns, cwd) {
	var externals, files, locals;

	if (typeof patterns === 'undefined') {
		return [];
	}

	patterns = (patterns instanceof Array) ? patterns : [patterns];
	cwd = cwd || process.cwd();

	externals = [];
	files = {};
	locals = {};

	each(patterns, function(pattern) {
		var globbed;

		globbed = glob.sync(pattern, {
			cwd: cwd
		});

		globbed.forEach(function(filename) {
			var file;

			file = new File(cwd, filename);
			files[file.path] = file;
		});
	});

	each(_flatten(files), function(file, path) {
		Array.prototype.push.apply(externals, file.external);
		locals[pubname(path, cwd)] = file;
	});

	unique(externals);

	return {
		externals: externals,
		locals: locals
	};
}
909404
private static function firstWildcardInPattern($pattern)
    {
        $wildcards = ['*', '?', '[', '\\'];
        $wildcardSearch = function ($carry, $item) use ($pattern) {
            $position = strpos($pattern, $item);

            if ($position === false) {
                return $carry === false ? $position : $carry;
            }

            return $carry === false ? $position : min($carry, $position);
        };

        return array_reduce($wildcards, $wildcardSearch, false);
    }