当前位置: 代码迷 >> J2SE >> 怎么替换字符串中包含问号的字符串
  详细解决方案

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

热度:81   发布时间:2016-04-24 00:48:05.0
如何替换字符串中包含问号的字符串
例如:
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";
  相关解决方案