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



  • 相关阅读:
    navigator
    历史记录跳转
    更改URL
    计数器
    窗口位置和大小
    open用法
    confirm用法
    项目中访问本地node服务跨域问题
    jenkins使用
    基于Vue的SSR
  • 原文地址:https://www.cnblogs.com/shixm/p/5730216.html
Copyright © 2011-2022 走看看