Prioritize exact match
553682
function (items, query) {
        if (!config.exactMatch || !config.searchField.name) {
          return items;
        }
        var list = items;
        var match = _.findIndex(list, function (item) {
          return query.toLowerCase() === item.name.toLowerCase();
        });
        if (match !== -1) {
          list.splice(0, 0, list.splice(match, 1)[0]);
        }
        return list;
      }
1070240
public Match match(List<String> desired, int threshold) {
    return matchImpl(parse(desired), threshold);
  }
270517
function matchSchedule (value, sequence) {
    for (var i = 0, c = sequence.length; i < c; i++) {
      if (sequence[i] >= value) {
        return sequence[i] === value;
      }
    }

    return sequence[0] === value;
  }
709382
def match_handle(loc, tokens):
    """"""
    if len(tokens) == 4:
        matches, match_type, item, stmts = tokens
        cond = None
    elif len(tokens) == 5:
        matches, match_type, item, cond, stmts = tokens
    else:
        raise CoconutInternalException("invalid match statement tokens", tokens)

    if match_type == "in":
        invert = False
    elif match_type == "not in":
        invert = True
    else:
        raise CoconutInternalException("invalid match type", match_type)

    matching = Matcher(loc, match_check_var)
    matching.match(matches, match_to_var)
    if cond:
        matching.add_guard(cond)
    return (
        match_to_var + " = " + item + "\n"
        + matching.build(stmts, invert=invert)
    )
565088
def match_indices(match):
    """"""
    a, b, size = match
    for i in range(size):
        yield a + i, b + i
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
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
1060037
function uniqueMatch(string, regexp) {
  const results = [];
  let match;

  while ((match = regexp.exec(string))) {
    results.push({
      context: match[0],
      match: match[1] || ''
    });
  }

  // Filter duplicates
  return unique(results, isEqual);
}
410214
@Override
    public int matches(Replaceable text,
                       int[] offset,
                       int limit,
                       boolean incremental) {
        int c;
        if (offset[0] < limit &&
            contains(c = text.char32At(offset[0]))) {
            offset[0] += UTF16.getCharCount(c);
            return U_MATCH;
        }
        if (offset[0] > limit && contains(text.char32At(offset[0]))) {
            // Backup offset by 1, unless the preceding character is a
            // surrogate pair -- then backup by 2 (keep offset pointing at
            // the lead surrogate).
            --offset[0];
            if (offset[0] >= 0) {
                offset[0] -= UTF16.getCharCount(text.char32At(offset[0])) - 1;
            }
            return U_MATCH;
        }
        if (incremental && offset[0] == limit) {
            return U_PARTIAL_MATCH;
        }
        return U_MISMATCH;
    }
316683
function matches(str, match) {
    if (Array.isArray(match)) return match.indexOf(str) > -1;
    return match.test(str);
}
1351138
def search_greater(values, target):
    
    first = 0
    last = len(values)

    while first < last:
        middle = (first + last) // 2
        if values[middle][0] < target:
            first = middle + 1
        else:
            last = middle

    return first
476820
def add_priority_rule(
        db, regexp: str, priority: Optional[int] = None,
) -> int:
    """"""
    with db:
        cur = db.cursor()
        if priority is None:
            cur.execute('SELECT MAX(priority) FROM file_priority')
            highest_priority = cur.fetchone()[0]
            if highest_priority is None:
                priority = 1
            else:
                priority = highest_priority + 1
        cur.execute("""
            INSERT INTO file_priority (regexp, priority)
            VALUES (?, ?)""", (regexp, priority))
        row_id = db.last_insert_rowid()
    return row_id
936849
def match(self, selector, index):
        """"""

        pseudo = None
        m = self.re_pseudo_name.match(selector, index)
        if m:
            name = util.lower(css_unescape(m.group('name')))
            pattern = self.patterns.get(name)
            if pattern:
                pseudo = pattern.match(selector, index)
                if pseudo:
                    self.matched_name = pattern

        return pseudo
1372558
private void handleMatch(Point match)
    {
        if (match == null)
        {
            int caretPosition = textComponent.getCaretPosition();
            Document document = textComponent.getDocument();
            caretPosition = Math.max(0, Math.min(
                document.getLength(), caretPosition));
            textComponent.setCaretPosition(caretPosition);
            textComponent.moveCaretPosition(caretPosition);
            textComponent.getCaret().setSelectionVisible(false);
        }
        else
        {
            textComponent.setCaretPosition(match.y);
            textComponent.moveCaretPosition(match.x);
            textComponent.getCaret().setSelectionVisible(true);
        }
    }
1091094
def search name, opts = {} 
      filter name, { exact: false, ignore_case: true, strip_blank: true }.merge(opts)
    end
508391
def match(self, category, pattern):
        """"""

        return fnmatch.fnmatch(category, pattern, flags=self.FNMATCH_FLAGS)
327884
private boolean matchCheck(int upperRange, int s, int prev, boolean interrupt) throws InterruptedException {
        if (Config.USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE) {
            if (Config.USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE) {
                //range = upperRange;
                if (matchAt(upperRange, s, prev, interrupt) != -1) {
                    if (!isFindLongest(regex.options)) return true;
                }
            } else {
                //range = upperRange;
                if (matchAt(upperRange, s, prev, interrupt) != -1) return true;
            }
        } else {
            if (Config.USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE) {
                if (matchAt(end, s, prev, interrupt) != -1) {
                    //range = upperRange;
                    if (!isFindLongest(regex.options)) return true;
                }
            } else {
                //range = upperRange;
                if (matchAt(end, s, prev, interrupt) != -1) return true;
            }
        }
        return false;
    }