matches each record against regexText according to parameters
    NOTE: the code could be written more simply, but this is loop-optimized to
          scale better with a large number of map records
350189
def filterMapNames(regexText,  records=getIndex(), excludeRegex=False, closestMatch=True):
    """"""
    bestScr = 99999 # a big enough number to not be a valid file system path
    regex = re.compile(regexText, flags=re.IGNORECASE)
    ret = []
    if excludeRegex: # match only records that do NOT contain regex
        if regexText and closestMatch: # then maps with fewer characters are better matches
            for m in list(records):
                if re.search(regex, m.name): continue # map must NOT contain specified phrase
                score = len(m.name) # the map with the smallest map name means it has the largets matching character percentage
                if score == bestScr:
                    bestScr = score
                    ret.append(m)
                elif score <  bestScr: # new set of best maps
                    bestScr = score
                    ret = [m]
        else: # all maps that match regex are included
            for m in list(records):
                if re.search(regex, m.name): continue # map must NOT contain specified phrase
                ret.append(m) # any mapname containing regex matches
    else: # only match records that contain regex
        if regexText and closestMatch: # then maps with fewer characters are better matches
            for m in records:
                if not re.search(regex, m.name): continue # map must contain specified phrase if excludeRegex==True
                score = len(m.name) # the map with the smallest map name means it has the largets matching character percentage
                if score == bestScr:
                    bestScr = score
                    ret.append(m)
                elif score <  bestScr: # new group of best maps
                    bestScr = score
                    ret = [m]
        else: # all maps that match regex are included
            for m in records:
                if not re.search(regex, m.name): continue # map must contain specified phrase if excludeRegex==True
                ret.append(m) # any mapname containing regex matches
    return ret
1286103
function match(key, val) {
    // Handle logical operators
    if (key[0] == "$") {
      if (key=="$and" || key=="$or") {
        if (!util.isArray(val))  { throw key+" operator used without an array" };

        var i = val.map(function(q) { return Cursor.getIdsForQuery(db, q) });
        var fn = key=="$and" ? _.intersection : _.union; // Merging function

        if (i.indexOf(null)>-1) indexed = false;
        else push(fn.apply(_, i));
      }

      if (key=="$not") {
        var i = Cursor.getIdsForQuery(db, val);

        if (i === null) indexed = false;
        else exclude(i);
      }

      // TODO: emit error here on "else"
      return;
    };

    // The query is not fully indexed - set the flag and build the index
    if (! (db.indexes[key] && db.indexes[key].ready)) {
      indexed = false;
      if (db.options.autoIndexing) db.ensureIndex({ fieldName: key });
    };

    // 1) We can utilize this index and 2) we should
    var index = db.indexes[key];
    if (index && (indexed || !db.options.autoIndexing)) {
      if (val===undefined) return push(index.getAll()); // Useful when we invoke match() in sort loop
      if (document.isPrimitiveType(val)) return push(index.getMatching(val));
      if (typeof(val)=="object" && !_.keys(val).some(function(k) { return document.comparators[k] })) return push(index.getMatching(val));

      // Those can be combined
      if (val && val.hasOwnProperty("$ne")) exclude(index.getMatching(val.$ne));
      if (val && val.hasOwnProperty("$in")) push(index.getMatching(val.$in));
      if (val && val.hasOwnProperty("$nin")) exclude(index.getMatching(val.$nin));
      if (val && val.hasOwnProperty("$lt") || val.hasOwnProperty("$lte") || val.hasOwnProperty("$gt") || val.hasOwnProperty("$gte")) push(index.getBetweenBounds(val));
      if (val && val.hasOwnProperty("$exists") && val.$exists==true) push(index.getAll(function(n) { return n.key!==undefined }));
      if (val && val.hasOwnProperty("$exists") && val.$exists==false) push(index.getAll(function(n) { return n.key===undefined }));
      if (val && val.hasOwnProperty("$regex")) { var r = val.$regex; push(index.getAll(function(n) { return n.key && n.key.match(r) })); }
    };
  }
943817
def matches(match_method, *params)
      return [] unless match_method.respond_to?(:yield)
      matches = match_method.yield(*params)
      return [] unless matches.respond_to?(:each)

      # We convert Nokogiri nodes to matches transparently
      matches.map do |m|
        if m.respond_to?(:node_name)
          match(m)
        elsif m.respond_to?(:xpath)
          m.to_a.map { |n| match(n) }
        else
          m
        end
      end.flatten
    end
1220722
def getRegexpsByName(regexpNames = ['all']):
    ''' 
        
    '''

    allRegexpList = getAllRegexp()
    if 'all' in regexpNames:
        return allRegexpList

    regexpList = []
    # going through the regexpList 
    for name in regexpNames:
        for r in allRegexpList:
            if name == r.name:
                regexpList.append(r)
    return regexpList
316683
function matches(str, match) {
    if (Array.isArray(match)) return match.indexOf(str) > -1;
    return match.test(str);
}
547011
def doctype_matches(text, regex):
    
    m = doctype_lookup_re.match(text)
    if m is None:
        return False
    doctype = m.group(2)
    return re.compile(regex, re.I).match(doctype.strip()) is not None
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);
}
572324
@Override
	public Map<RuleSet, List<Rule>> matching(Rules rules,
	                                         Map<String, Object> vars,
	                                         boolean ignoreMethodErrors) throws OgnlException
	{
		Map<RuleSet, List<Rule>> ret = new HashMap<>();

		for (RuleSet ruleSet : rules.ruleSets)
		{
			try
			{
				OgnlContext context = createContext(vars);

				List<Rule> matching = match(ruleSet, context);

				if (!matching.isEmpty())
				{
					ret.put(ruleSet, matching);
				}
			}
			catch (MethodFailedException mfe)
			{

				if (!ignoreMethodErrors)
				{
					throw mfe;
				}

				log.warn("Method failed for ruleset " + ruleSet.id, mfe);
			}
		}

		return ret;
	}
418112
def matchSubset(**kwargs):
        """"""
        ret = []
        for m in self.matches:
            allMatched = True
            for k,v in iteritems(kwargs):
                mVal = getattr(m, k)
                try:
                    if v == mVal or v in mVal: continue # this check passed
                except Exception: pass # if attempting to check __contains__ and exception is raised, it's assumed to be false
                allMatched = False
                break
            if allMatched: ret.append(m)
        return ret
1172565
def get_parameters(self, regex_exp, parameters):
        
        # TODO find a better way to do the equate replacement
        for rep in self.equates:
            parameters = parameters.replace(rep, str(self.equates[rep]))
        match = re.match(regex_exp, parameters)
        if not match:
            raise iarm.exceptions.ParsingError("Parameters are None, did you miss a comma?")

        return match.groups()
1190341
def match(m_templ, *m_args):
    
    # strip commented lines
    m_templ = '\n'.join(line for line in m_templ.splitlines()
                        if not line.lstrip().startswith('--'))
    if not m_args:
        return m_templ, ()
    try:
        return _Replacer(m_args).match(m_templ)
    except IndexError:
        raise ValueError('Incorrect number of ?-parameters in %s, expected %s'
                         % (m_templ, len(m_args)))
2733
def match_records(records)
      conditions = self.conditions
      records.select { |record| conditions.matches?(record) }
    end
60941
@Override
    public int matches(Replaceable text,
                       int[] offset,
                       int limit,
                       boolean incremental) {
        // Note (1): We process text in 16-bit code units, rather than
        // 32-bit code points.  This works because stand-ins are
        // always in the BMP and because we are doing a literal match
        // operation, which can be done 16-bits at a time.
        int i;
        int[] cursor = new int[] { offset[0] };
        if (limit < cursor[0]) {
            // Match in the reverse direction
            for (i=pattern.length()-1; i>=0; --i) {
                char keyChar = pattern.charAt(i); // OK; see note (1) above
                UnicodeMatcher subm = data.lookupMatcher(keyChar);
                if (subm == null) {
                    if (cursor[0] > limit &&
                        keyChar == text.charAt(cursor[0])) { // OK; see note (1) above
                        --cursor[0];
                    } else {
                        return U_MISMATCH;
                    }
                } else {
                    int m =
                        subm.matches(text, cursor, limit, incremental);
                    if (m != U_MATCH) {
                        return m;
                    }
                }
            }
            // Record the match position, but adjust for a normal
            // forward start, limit, and only if a prior match does not
            // exist -- we want the rightmost match.
            if (matchStart < 0) {
                matchStart = cursor[0]+1;
                matchLimit = offset[0]+1;
            }
        } else {
            for (i=0; i<pattern.length(); ++i) {
                if (incremental && cursor[0] == limit) {
                    // We've reached the context limit without a mismatch and
                    // without completing our match.
                    return U_PARTIAL_MATCH;
                }
                char keyChar = pattern.charAt(i); // OK; see note (1) above
                UnicodeMatcher subm = data.lookupMatcher(keyChar);
                if (subm == null) {
                    // Don't need the cursor < limit check if
                    // incremental is true (because it's done above); do need
                    // it otherwise.
                    if (cursor[0] < limit &&
                        keyChar == text.charAt(cursor[0])) { // OK; see note (1) above
                        ++cursor[0];
                    } else {
                        return U_MISMATCH;
                    }
                } else {
                    int m =
                        subm.matches(text, cursor, limit, incremental);
                    if (m != U_MATCH) {
                        return m;
                    }
                }
            }
            // Record the match position
            matchStart = offset[0];
            matchLimit = cursor[0];
        }

        offset[0] = cursor[0];
        return U_MATCH;
    }
550044
function(matches, index, tokens, regexValue) {
      var i = tokens.length;

      while (--i >= 0) {
        var token = tokens[i];
        var type = token.type;

        if (type === _Comment ||
            type === _WhiteSpace ||
            type === _LineTerminator) {
          continue;
        }

        var value = token.value;
        if (type === _Punctuator) {
          if (value === ')') {
            if (this.isValidRegExpPrefix(tokens, i + 1)) {
              break;
            }
          } else if (regexPrefixRe.test(value)) {
            break;
          }
        } else if ((type === _Keyword && regexPrefixRe.test(value)) ||
                   (type === _Template && value.slice(-2) === '${')) {
          break;
        }

        var parts = regexValue.match(tokenizeNotRegExpRe);
        splice.apply(matches, [index, 1].concat(parts));
        return true;
      }
      return false;
    }
1097951
private static void match_glob(GlobData mdata, Context cx,
                                   Scriptable scope, int count,
                                   RegExpImpl reImpl)
    {
        if (mdata.arrayobj == null) {
            mdata.arrayobj = cx.newArray(scope, 0);
        }
        SubString matchsub = reImpl.lastMatch;
        String matchstr = matchsub.toString();
        mdata.arrayobj.put(count, mdata.arrayobj, matchstr);
    }
1248623
def matching_lines(re)
      @lines.each_with_index.select{|text, linenum| re.match(text)}.map{
        |i| i[1]+1}
    end
612432
def matching(type, list)
      list.map do |plugin|
        (plugins_map(type) || {})[string2class(plugin)]
      end
    end