android手机邮箱密码,Android邮箱、IP地址、电话号码、密码、网址、手机等

package com.fsti.icop.util.regexp;

import java.util.regex.Matcher;

import java.util.regex.Pattern;

public final class RegExpValidatorUtils {

public static boolean isEmail(String str) {

String regex =

"^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";

return match(regex, str);

}

public static boolean isIP(String str) {

String num =

"(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)";

String regex = "^" + num + "\\." + num + "\\." + num + "\\." +

num + "$";

return match(regex, str);

}

public static boolean IsUrl(String str) {

String regex = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-

./?%&=]*)?";

return match(regex, str);

}

public static boolean IsTelephone(String str) {

String regex =

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

return match(regex, str);

}

public static boolean IsPassword(String str) {

String regex = "[A-Za-z]+[0-9]";

return match(regex, str);

}

public static boolean IsPasswLength(String str) {

String regex = "^\\d{6,18}$";

return match(regex, str);

}

public static boolean IsPostalcode(String str) {

String regex = "^\\d{6}$";

return match(regex, str);

}

public static boolean IsHandset(String str) {

String regex = "^[1]+[3,5]+\\d{9}$";

return match(regex, str);

}

public static boolean IsIDcard(String str) {

String regex = "(^\\d{18}$)|(^\\d{15}$)";

return match(regex, str);

}

public static boolean IsDecimal(String str) {

String regex = "^[0-9]+(.[0-9]{2})?$";

return match(regex, str);

}

public static boolean IsMonth(String str) {

String regex = "^(0?[[1-9]|1[0-2])$";

return match(regex, str);

}

public static boolean IsDay(String str) {

String regex = "^((0?[1-9])|((1|2)[0-9])|30|31)$";

return match(regex, str);

}

public static boolean isDate(String str) {

// 严格验证时间格式的(匹配[2002-01-31], [1997-04-30],

// [2004-01-01])不匹配([2002-01-32], [2003-02-29],

[04-01-01])

// String regex =

//

"^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((01,3-9])|(1[0-2]))-(29|30)))))$";

// 没加时间验证的YYYY-MM-DD

// String regex =

//

"^((((1[6-9]|[2-9]\\d)\\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$";

// 加了时间验证的YYYY-MM-DD 00:00:00

String regex =

"^((((1[6-9]|[2-9]\\d)\\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))

(20|21|22|23|[0-1]?\\d):[0-5]?\\d:[0-5]?\\d$";

return match(regex, str);

}

public static boolean IsNumber(String str) {

String regex = "^[0-9]*$";

return match(regex, str);

}

public static boolean IsIntNumber(String str) {

String regex = "^\\+?[1-9][0-9]*$";

return match(regex, str);

}

public static boolean IsUpChar(String str) {

String regex = "^[A-Z]+$";

return match(regex, str);

}

public static boolean IsLowChar(String str) {

String regex = "^[a-z]+$";

return match(regex, str);

}

public static boolean IsLetter(String str) {

String regex = "^[A-Za-z]+$";

return match(regex, str);

}

public static boolean IsChinese(String str) {

String regex = "^[\u4e00-\u9fa5],{0,}$";

return match(regex, str);

}

public static boolean IsLength(String str) {

String regex = "^.{8,}$";

return match(regex, str);

}

private static boolean match(String regex, String str) {

Pattern pattern = Pattern.compile(regex);

Matcher matcher = pattern.matcher(str);

return matcher.matches();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值