鉴于以下String
"ws([WM_10003] , {MD_1402359631813}{MV_200101010000024})"
我只需要替换"{MD_1402359631813}"
""
这个值如何解决这个问题。如何替换子串?
答案 0 :(得分:2)
您没有给我们太多帮助,但根据您的问题,我怀疑您忘记更新您的String参考。它就像这样简单,
String str = "ws([WM_10003] , {MD_1402359631813}{MV_200101010000024})";
String toRemove = "{MD_1402359631813}";
System.out.println("Before: " + str);
str = str.replace(toRemove, "");
System.out.println("After: " + str);
输出
Before: ws([WM_10003] , {MD_1402359631813}{MV_200101010000024})
After: ws([WM_10003] , {MV_200101010000024})