美文网首页
java正则表达式的运用

java正则表达式的运用

作者: 程序猿峰岑 | 来源:发表于2018-10-08 10:37 被阅读0次

    一  登录密码输入检测排除特殊字符和非合法字符的输入检测

    String pwd = mPwdEtn.getText.toString().trim();

    boolean isPwd = pwd .matches("[^\u4E00-\u9FA5]{6,16}"

    if(!isPwd ){

               //请输入有效的密码

    }

    二 检测有效手机号码的方法

    private boolean isTelPhoto(String mobiles) {

    Pattern p = Pattern

    .compile("^((13[0-9])|(15[^4,\\D])|(18[0-9])|(17[0-9]))\\d{8}$");

        Matcher m = p.matcher(mobiles);

        return m.matches();

    }

    相关文章

      网友评论

          本文标题:java正则表达式的运用

          本文链接:https://www.haomeiwen.com/subject/vrudaftx.html