/**
* 键盘上特殊符号
*/
public static final String SPECIAL_CHARACTER_REGEX = "[`~!@#$%^&*()_\\-+=<>?:\"{}|,.\\\\/;'\\[\\]、·~!@#¥%……&*()——\\-+={}|《》?:“”【】、;‘',。、]";
public static void main(String[] args) {
Matcher matcher = specialCharacter.matcher("gaegage&*%$&&");
boolean result1 = matcher1.find();//部分匹配就ture
boolean result2 = matcher1.matches();//完全匹配ture
String s = matcher1.replaceAll("ff");//符合条件的替换成ff
}
字符串判断包含键盘上特殊字符通过正则表达式
最新推荐文章于 2021-07-14 16:24:09 发布