zoukankan      html  css  js  c++  java
  • java中的正则表达式

    除了汉字、英文、数字之外的数字,自动过滤
    /**
     * 除了汉字、英文、数字之外的数字,自动过滤
     * @param str
     * @return
     * @throws PatternSyntaxException
     */
    private String stringFilter(String str) throws PatternSyntaxException {
        String regEx = "[^u4e00-u9fa5^a-zA-Z^0-9]";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        return m.replaceAll("");
    }
    View Code
    是否只包含汉字、数字或英文
    /**
     * 是否只包含汉字、数字或英文
     * @param str
     * @return
     * @throws PatternSyntaxException
     */
    private boolean isValidate(String str) throws PatternSyntaxException {
        String regEx = "[u4e00-u9fa5a-zA-Z0-9]+";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        return m.matches();
    }
    View Code



  • 相关阅读:
    delphi参数传递
    Delphi OO
    Delphi Excel
    Delphi Register
    西安前端交流会
    web前端开发教程系列-4
    web前端开发教程系列-3
    web前端开发教程系列-2
    web前端开发教程系列-1
    露个脸
  • 原文地址:https://www.cnblogs.com/shixm/p/5730216.html
Copyright © 2011-2022 走看看