如何替换下面的字符串。如何从字符串中删除单引号,使用替换
String test = "This is my Test's cases";
现在我更换““”用空间是指这样的:‘这是我的测试案例’ 我想:
1) replace("'","")
2) replaceAll("'","")
3) replace("\'","")
...但我没有得到任何需要的结果。
测试代码:
String test = "The First American's style";
System.out.println("old text::"+test);
test = test.replaceAll("'","\\'");
System.out.println("new text::"+test);
你的问题标题违背你的榜样。 – raina77ow 2014-09-11 06:37:16
您不必在字符串文字中跳过撇号。一个(单个)空间不是没有字符的空字符串(又名“空字符串”)。 – laune 2014-09-11 06:40:32
你的问题说“空格”并不意味着“”。 – 2014-09-11 06:42:11