同一主题: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