Hi,
I'm trying to use java.lang.String.replaceAll() to replace a string that exists within a string with no luck. I'm developing a smaller search engine and want to remove any occurrences of "common words" in query string. The common words are stored in an ArrayList.
The code is as follows
I use the replaceAll() with success if I use to remove the wild-card character some_string.replaceAll("\\*", ""); from some_string. But it wont work with my c_m variable.
Any ideas?
I'm trying to use java.lang.String.replaceAll() to replace a string that exists within a string with no luck. I'm developing a smaller search engine and want to remove any occurrences of "common words" in query string. The common words are stored in an ArrayList.
The code is as follows
Code:
// Create an iterator (common_words is a public variable)
Iterator it = common_words.iterator();
// Variable to contain the common word
String c_m = new String();
// Do it!
while ( it.hasNext() ) {
// Common word
c_m = (String)it.next();
// Replace common word if it exists
string.replaceAll(c_m, "");
}
// Return string
return string;
I use the replaceAll() with success if I use to remove the wild-card character some_string.replaceAll("\\*", ""); from some_string. But it wont work with my c_m variable.
Any ideas?