去除字符串中的双引号

str为“123
  • 1

如果一个双引号:

str1 = str.replace("\"","").replace("\"","");
  • 1

如果不确定有多少个双引号:

str2 = str.replace(/\"/g, "");
  • 1

此方法为替换,也可用于去除制定字符,如:

String str = "12/3";
str1 = str.replace("\/","");
str2 = str.replace(/\//g, "");

输出为: 
str1 = 123
str2 = 123

猜你喜欢

转载自blog.csdn.net/yangxiaobo118/article/details/79874879
今日推荐