Android手机、E-mail、QQ验证

阅读更多
    /**

     * 验证字符串是否是email

     * @param str

     * @return

     */

    public static boolean isEmail(String str) {

Pattern pattern = Pattern.compile("[//w//.//-]+@([//w//-]+//.)+[//w//-]+",Pattern.CASE_INSENSITIVE);

Matcher matcher = pattern.matcher(str);

if (matcher.matches()) {

return true;

}else {

return false;

}

}   



    /**

     * 验证是否是手机号码

     * @param str

     * @return

     */

    public static boolean isCellphone(String str) {

Pattern pattern = Pattern.compile("1[0-9]{10}");

Matcher matcher = pattern.matcher(str);

if (matcher.matches()) {

return true;

}else {

return false;

}

}



    /**

     * 验证是否是QQ号码

     * @param str

     * @return

     */

    public static boolean isQQ(String str) {

Pattern pattern = Pattern.compile("[1-9]{5,10}");

Matcher matcher = pattern.matcher(str);

if (matcher.matches()) {

return true;

}else {

return false;

}

}

你可能感兴趣的:(Android手机、E-mail、QQ验证)