java 判断字符串中是否有特殊字符

正则表达式

    /*
    * 判断字符串中是否有特殊字符
    * 有返回true 没有false
    *  
     * */
    public boolean specialCharacters(StringBuilder stb) {
        String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(stb);
        System.out.println(m.find());
        return m.find();
    }
发布了51 篇原创文章 · 获赞 69 · 访问量 9827

猜你喜欢

转载自blog.csdn.net/weixin_43671437/article/details/105012713