如何替換下面的字符串。如何從字符串中刪除單引號,使用替換
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