search for 1 or more words (must match all words in order)
429772
function grep(s) {
  return new RegExp(_.map(str(s).split(/\s/), _.escapeRegExp).join('.*'), 'i');
}
1086181
def search_previous(self):
        

        pattern = self.get_selected_text() or self.__search_pattern
        if not pattern:
            return False

        return self.search(pattern, **{"case_sensitive": True,
                                       "whole_word": False,
                                       "regular_expressions": False,
                                       "backward_search": True,
                                       "wrap_around": True})
1070603
function countNumMatches(contents, queryExpr) {
    if (!contents) {
        return 0;
    }
    var matches = contents.match(queryExpr);
    return matches ? matches.length : 0;
}
421782
function getMatches(str, re) {
  if (str == null) {
    return null;
  }
  if (re == null) {
    return null;
  }
  var results = [];
  var match;
  while ((match = re.exec(str)) !== null) {
    results.push(match[1]);
  }
  return results;
}
43857
def _search(self, trie, strings, limit=None):
        
        results = [trie.has_keys_with_prefix(s) for s in strings]
        if not any(results):
            return []
        for result, s in zip(results, strings):
            if result is True:
                return trie.values(s)[:limit]
718597
def query(self, search, query):
        '''
        
        '''
        if not query:
            return search

        included, excluded = [], []
        for term in query.split(' '):
            if not term.strip():
                continue
            if term.startswith('-'):
                excluded.append(term[1:])
            else:
                included.append(term)
        if included:
            search = search.query(self.multi_match(included))
        for term in excluded:
            search = search.query(~self.multi_match([term]))
        return search
1262288
def _search(self, search_state, include_current_position=False, count=1):
        
        assert isinstance(search_state, SearchState)
        assert isinstance(count, int) and count > 0

        text = search_state.text
        direction = search_state.direction
        ignore_case = search_state.ignore_case()

        def search_once(working_index, document):
            """
            Do search one time.
            Return (working_index, document) or `None`
            """
            if direction == IncrementalSearchDirection.FORWARD:
                # Try find at the current input.
                new_index = document.find(
                   text, include_current_position=include_current_position,
                   ignore_case=ignore_case)

                if new_index is not None:
                    return (working_index,
                            Document(document.text, document.cursor_position + new_index))
                else:
                    # No match, go forward in the history. (Include len+1 to wrap around.)
                    # (Here we should always include all cursor positions, because
                    # it's a different line.)
                    for i in range(working_index + 1, len(self._working_lines) + 1):
                        i %= len(self._working_lines)

                        document = Document(self._working_lines[i], 0)
                        new_index = document.find(text, include_current_position=True,
                                                  ignore_case=ignore_case)
                        if new_index is not None:
                            return (i, Document(document.text, new_index))
            else:
                # Try find at the current input.
                new_index = document.find_backwards(
                    text, ignore_case=ignore_case)

                if new_index is not None:
                    return (working_index,
                            Document(document.text, document.cursor_position + new_index))
                else:
                    # No match, go back in the history. (Include -1 to wrap around.)
                    for i in range(working_index - 1, -2, -1):
                        i %= len(self._working_lines)

                        document = Document(self._working_lines[i], len(self._working_lines[i]))
                        new_index = document.find_backwards(
                            text, ignore_case=ignore_case)
                        if new_index is not None:
                            return (i, Document(document.text, len(document.text) + new_index))

        # Do 'count' search iterations.
        working_index = self.working_index
        document = self.document
        for _ in range(count):
            result = search_once(working_index, document)
            if result is None:
                return  # Nothing found.
            else:
                working_index, document = result

        return (working_index, document.cursor_position)
1031156
def matches(text, what):
    '''
    
    
    '''
    return text.find(what) > -1 if is_string(what) else what.match(text)
499558
def findByBiSearch(self, strSeq) :
		""""""
		arr = self.encode(strSeq)
		return self._dichFind(arr[0], self, 0, lst = None)
949386
def highlight_matches(self):
        """"""
        if self.is_code_editor and self.highlight_button.isChecked():
            text = self.search_text.currentText()
            words = self.words_button.isChecked()
            regexp = self.re_button.isChecked()
            self.editor.highlight_found_results(text, words=words,
                                                regexp=regexp)
1193123
public List<String> matchAll(String text, int limit, boolean isDensityMatch, boolean isGreedMatch) {
		if(null == text){
			return null;
		}
		
		List<String> findedWords = new ArrayList<String>();
		WordTree current = this;
		int length = text.length();
		StringBuilder wordBuffer;//存放查找到的字符缓存。完整出现一个词时加到findedWords中，否则清空
		char currentChar;
		for (int i = 0; i < length; i++) {
			wordBuffer = StrUtil.builder();
			for (int j = i; j < length; j++) {
				currentChar = text.charAt(j);
//				Console.log("i: {}, j: {}, currentChar: {}", i, j, currentChar);
				if(StopChar.isStopChar(currentChar)){
					if(wordBuffer.length() > 0){
						//做为关键词中间的停顿词被当作关键词的一部分被返回
						wordBuffer.append(currentChar);
					}else{
						//停顿词做为关键词的第一个字符时需要跳过
						i++;
					}
					continue;
				}else if(false == current.containsKey(currentChar)){
					//非关键字符被整体略过，重新以下个字符开始检查
					break;
				}
				wordBuffer.append(currentChar);
				if(current.isEnd(currentChar)){
					//到达单词末尾，关键词成立，从此词的下一个位置开始查找
					findedWords.add(wordBuffer.toString());
					if(limit > 0 && findedWords.size() >= limit){
						//超过匹配限制个数，直接返回
						return findedWords;
					}
					if(false == isDensityMatch){
						//如果非密度匹配，跳过匹配到的词
						i = j;
					}
					if(false == isGreedMatch){
						//如果懒惰匹配（非贪婪匹配）。当遇到第一个结尾标记就结束本轮匹配
						break;
					}
				}
				current = current.get(currentChar);
				if(null == current){
					break;
				}
			}
			current = this;
		}
		return findedWords;
	}
522008
def regex_matches_to_indexed_words(matches):
    
    words = [dict(v, **dict([('sentence', i)]))
             for i, s in enumerate(matches['sentences'])
             for k, v in s.items() if k != 'length']
    return words
132313
def ismatch(text, pattern):
    """"""

    if hasattr(pattern, 'search'):
        return pattern.search(text) is not None
    else:
        return pattern in text if Config.options.case_sensitive \
            else pattern.lower() in text.lower()
348048
def find_start_of_previous_word(self, count=1, WORD=False):
        
        # Reverse the text before the cursor, in order to do an efficient
        # backwards search.
        text_before_cursor = self.text_before_cursor[::-1]

        regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
        iterator = regex.finditer(text_before_cursor)

        try:
            for i, match in enumerate(iterator):
                if i + 1 == count:
                    return - match.end(1)
        except StopIteration:
            pass
355396
def _fullmatch(pattern, text, *args, **kwargs):
    """"""
    match = re.match(pattern, text, *args, **kwargs)
    return match if match.group(0) == text else None
548098
def do_list(lookup, term):
    """"""

    space = lookup.keys()
    matches = fnmatch.filter(space, term)

    return [(m, translate(lookup, m)) for m in matches]
96503
def query(self,query_string,toprint=False):
		""""""
		qq=SearchTerm(query_string)
		matchcount=0
		matches=[]
		for word in self.words():
			for match in word.search(qq):
				matches.append(match)
				matchcount+=1
				if "Word" in str(type(match)):
					matchstr=""
				else:
					matchstr=str(match)
				if toprint:
					word.om(makeminlength(str(matchcount),int(being.linelen/6))+"\t"+makeminlength(str(word),int(being.linelen))+"\t"+matchstr)
		return matches