public class Test {
public static void main(String[] args){
String ss = regReplace("[1*:?23:/\\]");
System.out.println(ss);
}
public static String regReplace(String str){
// '*','/',':','?','[','\\',']'
String s = str.replaceAll("[\\\\\\*/:?\\[\\]]", "");
return s;
}
}


本文档详细介绍了如何在Java中使用`String`类的`replaceAll()`方法进行正则表达式替换,展示了如何移除特定字符如'*','/',':', '?'及特殊字符 '[', ']', ''。通过实例代码,读者可以学习到在实际编程中如何处理字符串操作技巧。

932

被折叠的 条评论
为什么被折叠?



