首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

怎么替换字符串中包含问号的字符串

2012-06-14 
如何替换字符串中包含问号的字符串例如:public class Test {public static void main(String[] args) {Str

如何替换字符串中包含问号的字符串
例如:
public class Test {

public static void main(String[] args) {
String str= "123abc?123";
System.out.println(str);
String s="c?1";
str=str.replaceAll(s,"");
System.out.println(str);

}
}
输出结果为:

123abc?123
23abc?23


而我希望的结果是
123abc?123
123ab23

[解决办法]

Java code
        String s = "c\\?1"; 

热点排行