文字列を置換せずに文字列内の単語を置き換える方法はありますか?文字列を使用せずに文字列を置換する
これはすべてハードコードされています。動的にする方法はありますか?私は動的にそれを作ることができるいくつかのライブラリファイルがあると聞いたが、私はあまりよく分からない。
私にいくつかの解決策を教えてもらえますか?どうもありがとうございました。この場合
for (int i = 0; i < results.size(); ++i) {
// To remove the unwanted words in the query
test = results.toString();
String testresults = test.replace("numFound=2,start=0,docs=[","");
testresults = testresults.replace("numFound=1,start=0,docs=[","");
testresults = testresults.replace("{","");
testresults = testresults.replace("SolrDocument","");
testresults = testresults.replace("numFound=4,start=0,docs=[","");
testresults = testresults.replace("SolrDocument{", "");
testresults = testresults.replace("content=[", "");
testresults = testresults.replace("id=", "");
testresults = testresults.replace("]}]}", "");
testresults = testresults.replace("]}", "");
testresults = testresults.replace("}", "");
[*正規表現(*)*](https://blog.codinghorror.com/regular-expressions-now-you-have-two-problems/)を使用してください。 –
result.toString()を実行しているだけでループするのはなぜですか?私は私が使用されて表示されません。ただ質問する... – alexbt
基本的に私はSolrから情報/コンテンツを取得しているので。しかし、結果を表示すると、私が置き換えたそれらの不要な単語が表示されます。それは静的であり、動的にしたいのです。 @Alex –