同一主題:replace String with another in java更換陣列字符串與其他數組字符串
我想更換String Replace = "SUM(NewCounter)+SUM(NewCounter2)+NewCounter3";
我Array A = {NewCounter, NewCounter2, NewCounter3}
說我有Array B = {test, testA, testB}
我想與陣列A
用數組來代替它B
in String Replace
。
我嘗試使用方法ReplaceAll(A.get(index), B.get(index));
問題是:
NewCounter2
由系統讀"NewCounter"+2
所以我有結果= String Replace = "SUM(test)+SUM(test2)+test3";
我嘗試在字符NewCounter使用' ,它將是Array A = {'NewCounter', 'NewCounter2', 'NewCounter3'}
但我必須改變字符串Replace
像在此之前:
String Replace = "SUM('NewCounter')+SUM('NewCounter2')+'NewCounter3'";
有沒有其他辦法我嗎? 我不想前改變串...
Thanksfull,
-mazipan-
讓我們看看你已經嘗試了什麼。 –
很難弄清楚你的問題意味着什麼。 –
重複[一次替換文件中的多個子串](https://stackoverflow.com/questions/7661460/replace-multiple-substrings-in-a-file-at-once)。 – Boann