18 package org.turro.elephant.search;
20 import java.util.Stack;
21 import java.util.regex.Matcher;
22 import java.util.regex.Pattern;
30 protected String
query, reQuery;
31 protected Pattern
pat;
41 pat = Pattern.compile(reQuery);
45 if(line ==
null)
return;
49 line = removeMacros(line);
50 Matcher mat =
pat.matcher(line);
56 line = line.replaceAll(
"(" + reQuery +
")",
"<span class='found'>$1</span>");
63 return lines.size() > 0;
68 for(
int i = 0; i <
lines.size(); i++) {
69 result +=
lines.get(i) +
"<br/>";
79 if(
query ==
null)
return "";
80 String[] values =
query.split(
"\\s+");
81 count = values.length;
82 String result =
"(", sep =
"";
83 for(
int i = 0; i <
count; i++) {
84 result += sep +
"(" + values[i] +
")";
87 return (
ignoreCase ?
"(?i)" :
"") + result +
")";
91 String[] values =
query.split(
"\\s+");
92 String result =
"(", sep =
"";
93 for(
int i = 0; i < values.length; i++) {
95 result += sep +
"UCASE(" + field +
") LIKE '%" + values[i].toUpperCase() +
"%' ";
98 result += sep + field +
" LIKE '%" + values[i] +
"%' ";
106 return line.replaceAll(
"\\<\\/?[\\?a-zA-Z\\-\\:\\_0-9]+\\ ?.*?\\>",
"");
110 return line.replaceAll(
"\\<" +
string +
" .*?\\<\\/" +
string +
"\\>",
"");
113 private static String removeMacros(String line) {
114 return line.replaceAll(
"\\{\\@[\\?\\&a-zA-Z\\-\\:\\_0-9\\ \\.]+\\}",
"");