Java取代一切?
我试图替换字符串中的一些字符,但它不起作用。你能帮帮我吗 我的代码是:Java取代一切?,java,replaceall,Java,Replaceall,我试图替换字符串中的一些字符,但它不起作用。你能帮帮我吗 我的代码是: String test = "ABC?!"; test = test.replaceAll("\\?",""); test= test.replaceAll("\\!, ""); 非常感谢您对我的帮助。试试str.replaceAll(“[?!]”,“)“它不工作”没有给我们任何信息。如果您不需要正则表达式,请使用replace(String,String)方法。此test.replaceAll(\\!,”);将永远无法工
String test = "ABC?!";
test = test.replaceAll("\\?","");
test= test.replaceAll("\\!, "");
非常感谢您对我的帮助。试试
str.replaceAll(“[?!]”,“)代码>“它不工作”没有给我们任何信息。如果您不需要正则表达式,请使用replace(String,String)
方法。此test.replaceAll(\\!,”);
将永远无法工作,您不能关闭双引号,请尝试test.replaceAll(\\!”,“”);而不是replace(“?”,“”)。replace(!,“”)
我想替换?
和!
?