recursive function to find matches
549626
function findByNameEx(args, matches) {

		// create a variable to store the matches
		matches = matches || [];
		
		// set option defaults
		args.name       = Array.isArray(args.name) ? args.name : [args.name];
		args.recursive  = (typeof(args.recursive) === 'boolean') ? args.recursive : false;
		args.limit      = !isNaN(args.limit) ? args.limit : 1;
		args.properties = args.properties || [];
		
		// check for a starting point, if one doesnt exist begin at the datacenter level
		if (!args.parent) {
			return rootSearch(args)
			.then(function(parents) {
				return findByNameEx({
					type       : args.type,
					name       : args.name,
					properties : args.properties,
					parent     : parents,
					recursive  : args.recursive,
					limit      : args.limit
				}, matches);
			});
		}
		
		// convert the parent to an array if it is not one
		args.parent = Array.isArray(args.parent) ? args.parent : [args.parent];
		
		// perform the search
		return Promise.each(args.parent, function(parent) {
			
			// check if the match limit is met
			if (matches.length >= args.limit) {
				return;
			}
			
			// perform the search on each name
			return Promise.each(args.name, function(name) {
				
				// check if the match limit is met
				if (matches.length >= args.limit) {
					return;
				}
				
				// perform the search
				return _client.getServiceContent({
					method: 'FindChild',
					service: 'searchIndex',
					params: {
						entity: util.moRef(parent.type, parent.id),
						name: name
					}
				})
				.then(function(result) {

					var id = _.get(result, '$value');
					
					if (id) {
						matches.push(id);
					}					
				});
			})
			.then(function() {
				
				// check if the match limit is met, if not and recursive
				// attempt to descend the child objects
				if (matches.length < args.limit && args.recursive) {
					
					// get the children of the current parent
					return _client.retrieve({
						type: parent.type,
						id: parent.id,
						properties: ['childEntity']
					})
					.then(function(mo) {

						var parents = [];
						
						// get all of the child folders
						_.forEach(_.get(mo, '[0].childEntity'), function(child) {
							if (child.match(/^group-.*/)) {
								parents.push({
									type: 'Folder',
									id: child
								});
							}
						});
						
						// if there were folders, recurse
						if (parents.length > 0) {
							return findByNameEx({
								type       : args.type,
								name       : args.name,
								properties : args.properties,
								parent     : parents,
								recursive  : args.recursive,
								limit      : args.limit
							}, matches);
						}
					});
				}
			});
		})
		.then(function() {
			return matches;
		});
	}
1219250
function(state, datasetId, items, matchFound, nestingLevel, stopExpandingParents) {
            // initialize whatever wasn't passed to a default value
            datasetId = datasetId || 'default';
            items = items || concealed.items[datasetId];
            matchFound = matchFound || false;
            nestingLevel = nestingLevel || 0;

            for (var i = items.length; --i >= 0;) {
                if (!!items[i].items && !!items[i].items.length) {
                    // matchFound here would mean that a match was found in a descendant
                    matchFound = visible.setActive(state, datasetId, items[i].items, matchFound, nestingLevel + 1, stopExpandingParents);
                    if (matchFound && !stopExpandingParents) {
                        items[i].expanded = true;
                        if (nestingLevel === 0) {
                            stopExpandingParents = true;
                        }
                    }
                } else {
                    if (matchFound) {
                        // matchFound here would mean either a sibling node or some other node was already matched
                        // so we want to skip the comparison to save time
                        items[i].isActive = false;
                    } else {
                        if (!!items[i].stateName && items[i].stateName === state) {
                            // if the item's state is the one being searched for then set the item to active and flip the matched flag
                            items[i].isActive = true;
                            matchFound = true;
                            stopExpandingParents = true;
                        } else {
                            items[i].isActive = false;
                        }
                    }
                }
            }

            return matchFound;
        }
843140
function matches(patterns) {
  if (!Array.isArray(patterns)) {
    if (typeof patterns === 'string') {
      return patterns.indexOf('!') === 0 ? [] : glob.sync(patterns);
    } else {
      return [];
    }
  }
  let result = [];
  patterns.forEach((pattern) => {
    const exclusion = pattern.indexOf('!') === 0;
    if (exclusion) {
      pattern = pattern.slice(1);
    }
    const arr = glob.sync(pattern);
    if (exclusion) {
      result = difference(result, arr);
    } else {
      result = union(result, arr);
    }
  });
  return result;
}
601270
def _fn_matches(fn, glob):
    """"""
    if glob not in _pattern_cache:
        pattern = _pattern_cache[glob] = re.compile(fnmatch.translate(glob))
        return pattern.match(fn)
    return _pattern_cache[glob].match(fn)
747649
def _recursive_compare(v1, v2):
    '''
    
    '''
    if isinstance(v1, list):
        if v2 is None:
            v2 = []
        if len(v1) != len(v2):
            return False
        v1.sort(key=_id_or_key)
        v2.sort(key=_id_or_key)
        for x, y in zip(v1, v2):
            if not _recursive_compare(x, y):
                return False
        return True
    elif isinstance(v1, dict):
        if v2 is None:
            v2 = {}
        v1 = dict(v1)
        v2 = dict(v2)
        if sorted(v1) != sorted(v2):
            return False
        for k in v1:
            if not _recursive_compare(v1[k], v2[k]):
                return False
        return True
    else:
        return v1 == v2
491536
function tryFindMatch() {
        var stack = [], ch, ok = true;;
        for (var runner = cursor; runner; runner = dir ? runner.nextSibling : runner.previousSibling) {
          if (runner.className == className && isSpan(runner) && (ch = paren(runner))) {
            if (forward(ch) == dir)
              stack.push(ch);
            else if (!stack.length)
              ok = false;
            else if (stack.pop() != matching[ch])
              ok = false;
            if (!stack.length) break;
          }
          else if (runner.dirty || !isSpan(runner) && !isBR(runner)) {
            return {node: runner, status: "dirty"};
          }
        }
        return {node: runner, status: runner && ok};
      }
921456
def match(self, s):
      
      if self.re.match(s):
         self.list.append(s)
         return True
      else: return False
574647
def match(self, s):
      
      self.matches = self.re.search(s)
      return self.matches
362552
def find(basedir, string):
    
    matches = []
    for root, dirnames, filenames in os.walk(basedir):
        for filename in fnmatch.filter(filenames, string):
            matches.append(os.path.join(root, filename))
    return matches
714493
def _match(filtered, matcher):
    """"""

    def match_filtered_identities(x, ids, matcher):
        """Check if an identity matches a set of identities"""

        for y in ids:
            if x.uuid == y.uuid:
                return True
            if matcher.match_filtered_identities(x, y):
                return True
        return False

    # Find subsets of matches
    matched = []

    while filtered:
        candidates = []
        no_match = []

        x = filtered.pop(0)

        while matched:
            ids = matched.pop(0)

            if match_filtered_identities(x, ids, matcher):
                candidates += ids
            else:
                no_match.append(ids)

        candidates.append(x)

        # Generate the new list of matched subsets
        matched = [candidates] + no_match

    return matched
313737
function findMatchingIndexes(selector, userFields, sortOrder, indexes) {

  return indexes.reduce(function (res, index) {
    var indexMatches = checkIndexMatches(index, sortOrder, userFields, selector);
    if (indexMatches) {
      res.push(index);
    }
    return res;
  }, []);
}
1073926
def findAll(haystack, needle) :
	""""""
	
	h = haystack
	res = []
	f = haystack.find(needle)
	offset = 0
	while (f >= 0) :
		#print h, needle, f, offset
		res.append(f+offset)
		offset += f+len(needle)
		h = h[f+len(needle):]
		f = h.find(needle)

	return res
1270400
def _build_matches(matches, uuids, no_filtered, fastmode=False):
    """"""

    result = []

    for m in matches:
        mk = m[0].uuid if not fastmode else m[0]
        subset = [uuids[mk]]

        for id_ in m[1:]:
            uk = id_.uuid if not fastmode else id_
            u = uuids[uk]

            if u not in subset:
                subset.append(u)

        result.append(subset)

    result += no_filtered
    result.sort(key=len, reverse=True)

    sresult = []
    for r in result:
        r.sort(key=lambda id_: id_.uuid)
        sresult.append(r)

    return sresult
1194253
def match?
      match = false
      @instance.current_node.recursive_children do |child_node|
        match = match || (child_node && child_node.match?(@rules))
      end
      !match
    end
429792
def matches(s, t, i, j, k):
    """"""
    for d in range(k):
        if s[i + d] != t[j + d]:
            return False
    return True
636723
def char_matches(s1, s2, n=3):
    
    return __matches(s1, s2, char_ngrams, n=n)
746562
def _get_stmt_matching_groups(stmts):
        """"""
        def match_func(x): return x.matches_key()

        # Remove exact duplicates using a set() call, then make copies:
        logger.debug('%d statements before removing object duplicates.' %
                     len(stmts))
        st = list(set(stmts))
        logger.debug('%d statements after removing object duplicates.' %
                     len(stmts))
        # Group statements according to whether they are matches (differing
        # only in their evidence).
        # Sort the statements in place by matches_key()
        st.sort(key=match_func)

        return itertools.groupby(st, key=match_func)