@Test public void contextLoads() { //b替换成w String word="a,b,c,d,e,f"; String[] split = word.split(","); String newword=""; for(String s:split){ if(!s.equals("b")){ newword+=s+","; } } newword+="w"+","; int idx = newword.lastIndexOf(","); String str1 = newword.substring(0,idx); System.out.println(str1); }
字符串:‘a,b,c,d,e,f’某个值 的替换
最新推荐文章于 2024-02-01 14:07:19 发布