public static void main(String[] args) {
String s = "a,b,'c,d','e,f',g,h,'i,j' ";
char[] c = s.toCharArray();
String sum = "";
int b = 0;
String f = "";
for (int i = 0; i < c.length; i++) {
String a = String.valueOf(c[i]);
if (b == 0) {
sum += c[i];
}
if (a.equals("'")) {
b++;
}
if (b == 1) {
f += show(b, a);
}
if (b ==2){
String j = show2(f);
sum += j;
b=0;
f="";
}
}
String h = sum;
System.out.println(h.replace("'", ""));
}
public static String show2(String f) {
String j = f.replace(",", "");
return j;
}
public static String show(int count, String str) {
String s = "";
if (count == 2) {
return "";
} else {
s += str;
}
return s;
}
字符串中去掉单双引号和单引号里的
最新推荐文章于 2024-07-08 02:54:29 发布