字符串判断包含键盘上特殊字符通过正则表达式

it2024-10-02  42

/** * 键盘上特殊符号 */ 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 }
最新回复(0)