the rules used for matching
968954
public static void tearDownExample(DatabaseClient client) {
    XMLDocumentManager docMgr = client.newXMLDocumentManager();

    for (String filename: filenames) {
      docMgr.delete("/example/"+filename);
    }

    RuleManager ruleMgr = client.newRuleManager();

    ruleMgr.delete(RULE_NAME);
  }
1109620
def _match(self):
        """"""
        #disable optimized matching
        optimized_rows = None
        optimized_columns = None
        for match in self.__match_rows(optimized_rows):
            #match in rows
            yield match
        for match in self.__match_rows(optimized_columns,
                                       transpose=True):
            #match in columns and transpose coordinates
            yield match
203363
function(matchRules, text, change) {
  const { startOffset, endOffset, focusText } = change.state;
  const focusedText = focusText.text;
  change.moveOffsetsTo(0);
  let length = 0;
  for (let i = 0, k = matchRules.length; i < k; i++) {
    const result = matchRules[i].exec(focusedText);
    if (result) {
      length = result[0].length;
      change.deleteForward(length);
      break;
    }
  }
  const startPos = Math.max(startOffset + text.length - length, 0);
  const endPos = Math.max(endOffset + text.length - length, 0);
  change.insertText(text).moveOffsetsTo(startPos, endPos).focus();

  return change;
}
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;
}
836483
def check_next_match(self, match, new_relations, subject_graph, one_match):
        """"""
        # only returns true for ecaxtly one set of new_relations from all the
        # ones that are symmetrically equivalent
        if not (self.criteria_sets is None or one_match):
            for check in self.duplicate_checks:
                vertex_a = new_relations.get(check[0])
                vertex_b = new_relations.get(check[1])
                if vertex_a is None and vertex_b is None:
                    continue # if this pair is completely absent in the new
                    # relations, it is either completely in the match or it
                    # is to be matched. So it is either already checked for
                    # symmetry duplicates, or it will be check in future.
                if vertex_a is None:
                    # maybe vertex_a is in the match and vertex_b is the only
                    # one in the new relations. try to get vertex_a from the
                    # match.
                    vertex_a = match.forward.get(check[0])
                    if vertex_a is None:
                        # ok, vertex_a is to be found, don't care about it right
                        # now. it will be checked in future calls.
                        continue
                elif vertex_b is None:
                    # maybe vertex_b is in the match and vertex_a is the only
                    # one in the new relations. try to get vertex_b from the
                    # match.
                    vertex_b = match.forward.get(check[1])
                    if vertex_b is None:
                        # ok, vertex_b is to be found, don't care about it right
                        # now. it will be checked in future calls.
                        continue
                if vertex_a > vertex_b:
                    # Why does this work? The answer is not so easy to explain,
                    # and certainly not easy to find. if vertex_a > vertex_b, it
                    # means that there is a symmetry operation that leads to
                    # an equivalent match where vertex_b < vertex_a. The latter
                    # match is preferred for as much pairs (vertex_a, vertex_b)
                    # as possible without rejecting all possible matches. The
                    # real difficulty is to construct a proper list of
                    # (vertex_a, vertex_b) pairs that will reject all but one
                    # matches. I conjecture that this list contains all the
                    # first two vertices from each normalized symmetry cycle of
                    # the pattern graph. We need a math guy to do the proof. -- Toon
                    return False
            return True
        return True
1339156
function Matcher (patternFn, successFn, next) {
    this.patternFn = patternFn;
    this.successFn = successFn;
    this.next = next;
  }
1258072
function matches(str, match) {
    if (Array.isArray(match)) {
        var l = match.length;
        for( var s=0; s < l; s++) {
            if ( mm(str,match[s])) {
                return true;
            }
        }
        return false;
    }
    return match.test(str);
}
764317
def matchesWithMatchers(self, event):
        '''
        
        '''
        ret = []
        self._matches(event, set(), ret)
        return tuple(ret)
313386
def __matches(s1, s2, ngrams_fn, n=3):
    
    ngrams1, ngrams2 = set(ngrams_fn(s1, n=n)), set(ngrams_fn(s2, n=n))
    return ngrams1.intersection(ngrams2)
545454
def match(self, files):
        """"""
        if not files:
            return set()

        if (self.matched_inherit.all_files()
                or self.matched_and_subdir.all_files()
                or self.matched_no_subdir.all_files()):
            # Optimization: one of the matched patterns matches everything
            # So simply return it
            return set(files)

        unmatched = set(files)
        matched = set()
        for pattern_set in self._matching_pattern_sets():
            pattern_set.match_files(matched, unmatched)
            if not unmatched:
                # Optimization: If we have matched all files already
                # simply return at this point - nothing else to do
                break

        return matched
669923
private boolean groupInfoMatches(Map<String, List<GroupInfo>> a, Map<String, List<GroupInfo>> b) {
        if (a == null && b == null) {
            return true;
        }

        boolean isMatch = false;
        if (a != null && b != null) {
            if (a.isEmpty() && b.isEmpty()) {
                isMatch = true;
            } else if (a.size() == b.size()) {
                for (Entry<String, List<GroupInfo>> entry : a.entrySet()) {
                    List<GroupInfo> otherList = b.get(entry.getKey());
                    isMatch = (otherList != null);
                    if (!isMatch) {
                        break;
                    }

                    List<GroupInfo> thisList = entry.getValue();
                    isMatch = otherList.containsAll(thisList) && thisList.containsAll(otherList);
                    if (!isMatch) {
                        break;
                    }
                }
            }
        }
        return isMatch;
    }
818615
def _match(self, struct1, struct2, fu, s1_supercell=True, use_rms=False,
               break_on_match=False):
        
        ratio = fu if s1_supercell else 1/fu
        if len(struct1) * ratio >= len(struct2):
            return self._strict_match(
                struct1, struct2, fu, s1_supercell=s1_supercell,
                break_on_match=break_on_match, use_rms=use_rms)
        else:
            return self._strict_match(
                struct2, struct1, fu, s1_supercell=(not s1_supercell),
                break_on_match=break_on_match, use_rms=use_rms)
744234
function selectorsEqual (ruleA, ruleB) {
  return ruleA.selectors.some(sel => {
    return ruleB.selectors.some(s => s === sel)
  })
}
822182
protected void greedyMatch() {
        for (int w = 0; w < dim; w++) {
            for (int j = 0; j < dim; j++) {
                if (matchJobByWorker[w] == -1
                        && matchWorkerByJob[j] == -1
                        && costMatrix[w][j] - labelByWorker[w] - labelByJob[j] == 0) {
                    match(w, j);
                }
            }
        }
    }
58294
def p_matcharglist(p):
    '''
    
    '''
    if len(p) == 2:
        p[0] = [p[1]]

    else:
        p[0] = p[1]
        p[0].append(p[3])
626302
def rules(self, x, y):
        # type: (int, int) -> List[Type[Rule]]
        
        return [r for r in self._field[y][x]]
901112
public function setupRules()
    {
        $this->rules->addMany([
            'call.symbol' => new Rule(new RegexMatcher('/(\\\[a-z@]+)/si'), [
                'context' => ['!delimiter.environment'],
                'priority' => -1
            ]),

            'expression.math' => [
                new Rule(new RegexMatcher('/((\${1,2}).*?\2)/s')),
                new Rule(new RegexMatcher('/(\\\\\(.*?\\\\\))/s')),
                new Rule(new RegexMatcher('/(\\\\\[.*?\\\\\])/s')),
                new Rule(
                    new RegexMatcher(
                        '/\\\begin{((?:' . implode('|', self::$mathEnvironments) . ')\*?)}(.*?)\\\end{\1}/s',
                        [2 => Token::NAME]
                    )
                )
            ],

            'delimiter.math' => new Rule(new WordMatcher(['$', '\[', '\]', '\(', '\)'], ['separated' => false]), [
                'context' => ['expression.math']
            ]),

            'symbol.annotation'    => new Rule(new RegexMatcher('/\[(.*?)\]/')), // make argument parsing?
            'symbol.environment' => new Rule(new RegexMatcher('/(\\\(?:begin|end)){(.*?)}/', [
                1 => 'delimiter.environment',
                2 => Token::NAME
            ]), ['context' => Validator::everywhere()]),

            'symbol.label' => new Rule(new RegexMatcher('/\\\(?:label|ref){(.*?)}/')),

            'operator' => [
                new Rule(new WordMatcher(['*', '&', '@', '\\\\'], ['separated' => false]), ['context' => Validator::everywhere()]),
                new Rule(new WordMatcher(['=', '-', '+', '/', '^', '_'], ['separated' => false]), [
                    'context'  => ['expression.math'],
                    'priority' => -1
                ]),
                'punctuation.brackets' => new Rule(new WordMatcher(['{', '}', '[', ']', '(', ')'], ['separated' => false]), [
                    'context' => ['expression.math']
                ]),
                'escape' => new Rule(new RegexMatcher('/(\\\[%@&])/si'), ['context' => Validator::everywhere(), 'priority' => -1])

            ],
            'comment' => new Rule(new CommentMatcher(['%'], [])),

            'format.bold' => new Rule(new RegexMatcher('/\\\textbf({((?>[^{}]+|(?1))+)})/si', [
                2 => Token::NAME
            ])),
            'format.italics' => new Rule(new RegexMatcher('/\\\textit({((?>[^{}]+|(?1))+)})/si', [
                2 => Token::NAME
            ])),

            'variable' => new Rule(new RegexMatcher('/(#\d+)/')),

            # math mode
            'number' => new Rule(new RegexMatcher('/(-?(?:0[0-7]+|0[xX][0-9a-fA-F]+|0b[01]+|[\d,.]+))/'), [
                'context'  => ['expression.math'],
                'priority' => -2
            ]),
        ]);
    }