def hilite_search_criteria(pattern, search_criteria)
return if pattern.nil? or search_criteria.nil?

pattern.gsub!(/(<[^>]*>)|\n|\t/s) {” “}

match_char = pattern =~ /#{search_criteria}/i
matched_string = $~.to_s

return if match_char.nil?
start = match_char – 25
start = (start < 0 ? 0 : start) unless match_char.nil? p = pattern[start ... match_char + search_criteria.length + 25] match_char = pattern =~ /#{search_criteria}/i p[match_char, matched_string.length ] = '‘ + matched_string + “
return p
end
end

By Jason

Leave a Reply

Your email address will not be published. Required fields are marked *