MCPcopy Create free account
hub / github.com/SeanDragon/protools / RegexConst

Class RegexConst

common/src/main/java/pro/tools/constant/RegexConst.java:13–122  ·  view source on GitHub ↗

正则的常量 @author SeanDragon @date 2017-04-17 10:13

Source from the content-addressed store, hash-verified

11 * @date 2017-04-17 10:13
12 */
13public final class RegexConst {
14
15 /**
16 * 正则:金额
17 */
18 public static final Pattern REGEX_MONEY = compile("^(([1-9]\\d*)|0)(\\.\\d{1,2})?$");
19 /**
20 * 正则:英文单词或者数字
21 */
22 public static final Pattern REGEX_WORD_OR_NUMBER = compile("^[A-Za-z0-9]+$");
23 /**
24 * 正则:手机号(简单)
25 */
26 public static final Pattern REGEX_MOBILE_SIMPLE = compile("^[1]\\d{10}$");
27 /**
28 * 正则:手机号(精准)
29 * 13 14 15 16 17 18 19 开头都可以
30 */
31 public static final Pattern REGEX_MOBILE_EXACT = compile("^1[3|4|5|6|7|8|9][0-9]\\d{8}$");
32 // public static final Pattern REGEX_MOBILE_EXACT = compile("^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|(147))\\d{8}$");
33 /**
34 * 正则:电话号码
35 */
36 public static final Pattern REGEX_TEL = compile("^0\\d{2,3}[- ]?\\d{7,8}");
37 /**
38 * 正则:身份证号码15位
39 */
40 public static final Pattern REGEX_ID_CARD15 = compile("^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$");
41 /**
42 * 正则:身份证号码18位
43 */
44 public static final Pattern REGEX_ID_CARD18 = compile("^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$");
45 /**
46 * 正则:邮箱
47 */
48 public static final Pattern REGEX_EMAIL = compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
49 /**
50 * 正则:URL
51 */
52 public static final Pattern REGEX_URL = compile("^(http|https)://.*$");
53 //public static final Pattern REGEX_URL = compile("[a-zA-z]+://[^\\s]*");
54 /**
55 * 正则:汉字
56 */
57 public static final Pattern REGEX_ZH = compile("^[\\u4e00-\\u9fa5]+$");
58 /**
59 * 正则:用户名,取值范围为a-z,A-Z,0-9,"_",汉字,不能以"_"结尾,用户名必须是6-20位
60 */
61 public static final Pattern REGEX_USERNAME = compile("^[A-Za-z\\u4e00-\\u9fa5]{4,30}(?<!_)$");
62 /**
63 * 正则:yyyy-MM-dd格式的日期校验,已考虑平闰年
64 */
65 public static final Pattern REGEX_DATE = compile("^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$");
66 /**
67 * 正则:IP地址
68 */
69 public static final Pattern REGEX_IP = compile("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");
70 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected