例如在mysql資料庫中建表時表名不能使用特殊符号,‘-’,‘{}’等等,是以我們要篩選去掉
public static void main(String[] args) {
String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?-]";
String str = "dKdcfe_2018年軟體基地年報1、(130000)-20190806102546_20211103";
String newString = str.replaceAll(regEx, "");//不想保留原來的字元串可以直接寫成 “str =
System.out.println(newString);
}
篩選完後: