次の文字列の組み合わせを置き換える方法: word1="word2"
次の文字列の組み合わせ: word1="word3"
単語境界の 使用\b
。
以下を使用しましたが、機能しませんでした:
String word2 = "word2";
String word3 = "word3";
String oldLine = "word1=\"" + word2 + "\"";
String newLine = "word1=\"" + word3 + "\"";
String lineToReplace = "\\b" + oldLine + "\\b";
String changedCont = cont.replaceAll(lineToReplace, newLine);
word1 ="word2"文字列の組み合わせcont
を含む多くの文字を含む文字列です。