我的阵列:
["12","empty","22"],["13","23","33"]]
我的正则表达方式:
arr.replace("\"empty\"", "")
String[] array = arr.split("\",\"");
输出
["12",,"22"],["13","23","33"]]
在我的字符串数组中替换之后删除逗号的最佳方法是什么?
答案 0 :(得分:0)
这样可行。
String arr="[\"12\",\"empty\",\"22\"],[\"13\",\"23\",\"33\"]]";
System.out.println("Input: "+arr);
System.out.println("Result: "+arr.replaceAll("\"empty\",?",""));
给出
Input: ["12","empty","22"],["13","23","33"]]
Result: ["12","22"],["13","23","33"]]