非法字符的正则表达式

来源:互联网 发布:中级java工程师面试题 编辑:程序博客网 时间:2024/04/30 18:46

public final static String SEARCHKEYREGEX = "[~!/@#$%^&*()\\-_=+\\|[{}];:\'\",<.>/?]+";

//!@~#¥%……&*()——+{}|:“《》?-=【】、;‘,。、

 

public static void main(String []a )
    {
        Matcher m = null;
        String searchKey = "1!";
        if(StringUtils.isNotEmpty(searchKey))
        {
            System.out.println(SEARCHKEYREGEX);
            Pattern p = Pattern.compile(SEARCHKEYREGEX);    
            m = p.matcher(searchKey);
            System.out.println(m.find());
        }
       
    }

0 0
原创粉丝点击