Public:

 search_term - The String or Regexp to look for.
 Public: format a line with matched term(s).

 line - The String line to be displayed.
 num  - The Integer number of the line (in base 1).

 Returns a formatted String.
176541
def line line, num
      begin
        line.strip!
      rescue Exception => ex
        puts "Error ".background(:red) + ex.message
      end
      "#{'%4i' % num}| #{Colorizer::for_line(line, @search_term)}"
    end
5918
def findSynonyms(self, word, num):
        
        if not isinstance(word, basestring):
            word = _convert_to_vector(word)
        words, similarity = self.call("findSynonyms", word, num)
        return zip(words, similarity)
1345491
public static String termPrefix(String term) {
    int i = term.indexOf(MtasToken.DELIMITER);
    String prefix = term;
    if (i >= 0) {
      prefix = term.substring(0, i);
    }
    return prefix.replace("\u0000", "");
  }
1257141
def term_regex(term):
    
    return re.compile(r'^{0}$'.format(re.escape(term)), re.IGNORECASE)
1288758
def do_search(self, line):
        
        args = self._split_args(line, 0, -1)
        query = " ".join([_f for _f in args if _f])
        self._command_processor.search(query)
572097
function highlight_term(value, term) {
          return value.replace(
            new RegExp(
              "(?![^&;]+;)(?!<[^<>]*)(" + regexp_escape(term) + ")(?![^<>]*>)(?![^&;]+;)",
              "gi"
            ), function(match, p1) {
              return "<b>" + escapeHTML(p1) + "</b>";
            }
          );
      }
1288041
def query_term(term)
      # rubocop:disable Style/GuardClause
      if term.is_a?(Symbol)
        return term.to_s
      elsif term.is_a?(Integer)
        return term
      elsif term.is_a?(TrueClass)
        return term
      elsif !term.is_a?(Term)
        return "'#{term}'"
      end
      # rubocop:enable Style/GuardClause
      terms = term.args.map { |t| query_term(t) }
      case term.operator.symbol
      when :_and
        { :$and => terms }
      when :_or
        { :$or => terms }
      when :_not
        # $not currently (<=2.5.1) only supports negating equality operators.
        # so you can do { field: { $not : { [$eq,$gt,$lt,...] } }
        # but there is no way to negate an entire expression.
        # see https://jira.mongodb.org/browse/SERVER-10708
        { :$nor => terms }
      when :_equal
        { term.args[0] => stringify(term.args[1]) }
      when :_not_equal
        { term.args[0] => { :$ne => stringify(term.args[1]) } }
      when :_match
        { term.args[0] => { :$regex => term.args[1].to_s } }
      when :_in
        { term.args[0] => { :$in => term.args[1] } }
      when :_greater
        { term.args[0] => { :$gt => term.args[1] } }
      when :_greater_or_equal
        { term.args[0] => { :$gte => term.args[1] } }
      when :_less
        { term.args[0] => { :$lt => term.args[1] } }
      when :_less_or_equal
        { term.args[0] => { :$lte => term.args[1] } }
      else
        raise "can't handle operator '#{term.operator}' yet"
      end
    end
219664
def candidates(text):
        
        for Pmatch in finditer(TARGET, text):
            # the punctuation mark itself
            P = Pmatch.group(1)
            # is it a boundary?
            B = bool(match(NEWLINE, Pmatch.group(5)))
            # L & R
            start = Pmatch.start()
            end = Pmatch.end()
            Lmatch = search(LTOKEN, text[max(0, start - BUFSIZE):start])
            if not Lmatch:  # this happens when a line begins with '.'
                continue
            L = word_tokenize(" " + Lmatch.group(1))[-1]
            Rmatch = search(RTOKEN, text[end:end + BUFSIZE])
            if not Rmatch:  # this happens at the end of the file, usually
                continue
            R = word_tokenize(Rmatch.group(1) + " ")[0]
            # complete observation
            yield Observation(L, P, R, B, end)
93792
def _regexp(expr, item):
    ''' 
    '''
    reg = re.compile(expr)
    return reg.search(item) is not None
926044
def term_str2code(term_str):
    
    result = ENV['TERM_PATTERN'].match(term_str).groups()
    year = int(result[0])
    return cal_term_code(year, result[1] == '一')
775097
function checkSearchTerm(searchTerm){
		if (!is_string(searchTerm) && !is_numeric(searchTerm)){
			console.log('\nError: This must be either a string or an interval:\n', searchTerm, ' \n');
			return false;
		} else {
			return true;
		}
	}
338004
def search(self, query, search_fields=None):
        

        # ### DETERMINE FIELDS TO SEARCH ###

        # Use search_fields arg if given, otherwise use search_fields
        # initially configured by the manager class.
        if search_fields:
            self._search_fields = search_fields_to_dict(search_fields)
        if not self._search_fields:
            return self.none()

        # ### BUILD LIST OF TERMS TO SEARCH FOR ###

        # Remove extra spaces, put modifiers inside quoted terms.
        terms = " ".join(query.split()).replace("+ ", "+")     \
                                       .replace('+"', '"+')    \
                                       .replace("- ", "-")     \
                                       .replace('-"', '"-')    \
                                       .split('"')
        # Strip punctuation other than modifiers from terms and create
        # terms list, first from quoted terms and then remaining words.
        terms = [("" if t[0:1] not in "+-" else t[0:1]) + t.strip(punctuation)
            for t in terms[1::2] + "".join(terms[::2]).split()]
        # Remove stop words from terms that aren't quoted or use
        # modifiers, since words with these are an explicit part of
        # the search query. If doing so ends up with an empty term
        # list, then keep the stop words.
        terms_no_stopwords = [t for t in terms if t.lower() not in
            settings.STOP_WORDS]
        get_positive_terms = lambda terms: [t.lower().strip(punctuation)
            for t in terms if t[0:1] != "-"]
        positive_terms = get_positive_terms(terms_no_stopwords)
        if positive_terms:
            terms = terms_no_stopwords
        else:
            positive_terms = get_positive_terms(terms)
        # Append positive terms (those without the negative modifier)
        # to the internal list for sorting when results are iterated.
        if not positive_terms:
            return self.none()
        else:
            self._search_terms.update(positive_terms)

        # ### BUILD QUERYSET FILTER ###

        # Create the queryset combining each set of terms.
        excluded = [reduce(iand, [~Q(**{"%s__icontains" % f: t[1:]}) for f in
            self._search_fields.keys()]) for t in terms if t[0:1] == "-"]
        required = [reduce(ior, [Q(**{"%s__icontains" % f: t[1:]}) for f in
            self._search_fields.keys()]) for t in terms if t[0:1] == "+"]
        optional = [reduce(ior, [Q(**{"%s__icontains" % f: t}) for f in
            self._search_fields.keys()]) for t in terms if t[0:1] not in "+-"]
        queryset = self
        if excluded:
            queryset = queryset.filter(reduce(iand, excluded))
        if required:
            queryset = queryset.filter(reduce(iand, required))
        # Optional terms aren't relevant to the filter if there are
        # terms that are explicitly required.
        elif optional:
            queryset = queryset.filter(reduce(ior, optional))
        return queryset.distinct()
620936
def prepareQueryTerm(self, field, term):
        
        if term == "*":
            return term
        addstar = False
        if term[len(term) - 1] == '*':
            addstar = True
            term = term[0 : len(term) - 1]
        term = self.escapeQueryTerm(term)
        if addstar:
            term = '%s*' % term
        if self.getSolrType(field) in ['string', 'text', 'text_ws']:
            return '"%s"' % term
        return term
602270
def findSynonyms(self, word, num):
        
        if not isinstance(word, basestring):
            word = _convert_to_vector(word)
        return self._call_java("findSynonyms", word, num)
375720
def parseSearchTerm(term):
    
    terms = []
    keywords = {}
    for word in term.split():
        if word.count(':') == 1:
            k, v = word.split(u':')
            if k and v:
                keywords[k] = v
            elif k or v:
                terms.append(k or v)
        else:
            terms.append(word)
    term = u' '.join(terms)
    if keywords:
        return term, keywords
    return term, None
1148170
function(item, term) {
            var numContextWords = 2;
            var text = item.content.match(
                "(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}" +
                    term+"(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}");
            item.context = text;
            return '<div class="autocomplete-suggestion" ' +
                'data-term="' + term + '" ' +
                'data-title="' + item.title + '" ' +
                'data-uri="'+ item.uri + '" ' +
                'data-context="' + item.context + '">' +
                '» ' + item.title +
                '<div class="context">' +
                (item.context || '') +'</div>' +
                '</div>';
        }
593843
def search_with_additional_term_string(self, filterstr):
        
        filterstr = "(&{}{})".format(self.filterstr, filterstr)

        return self.__class__(
            self.base_dn, self.scope, filterstr, attrlist=self.attrlist
        )