1818// ___`. | .'___
1919// (______|______)
2020//=======================================================
21+
2122/**
2223 * @author Seven<p>
23- * @date 2016年6月4日-下午4:07:25
24+ * @date 2016年6月4日-下午4:07:25
2425 */
26+ @ Deprecated
2527public class RegHelper {
2628
27- public static final String _REG_INT = "^\\ d+$" ;
28- public static final String _REG_STRING = "Null" ;
29- public static final String _REG_FLOAT = "\\ d+\\ .\\ d+" ;
30- public static final String _REG_DATE = "^((\\ d{2}(([02468][048])|([13579][26]))[\\ -\\ /\\ s]?((((0?[13578])|(1[02]))[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])))))|(\\ d{2}(([02468][1235679])|([13579][01345789]))[\\ -\\ /\\ s]?((((0?[13578])|(1[02]))[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\ -\\ /\\ s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))" ;
31- public static final String _REG_EMAIL = "\\ w+([-+.]\\ w+)*@\\ w+([-.]\\ w+)*\\ .\\ w+([-.]\\ w+)*" ;
32- public static final String _REG_PHONE = "^[1]([3][0-9]{1}|59|58|88|89)[0-9]{8}$" ;
33- private static HashMap <String , Pattern > Require_Cache ;
29+ public static final String _REG_INT = "^\\ d+$" ;
30+ public static final String _REG_STRING = "Null" ;
31+ public static final String _REG_FLOAT = "\\ d+\\ .\\ d+" ;
32+ public static final String _REG_DATE = "^((\\ d{2}(([02468][048])|([13579][26]))[\\ -\\ /\\ s]?((((0?[13578])|(1[02]))[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])))))|(\\ d{2}(([02468][1235679])|([13579][01345789]))[\\ -\\ /\\ s]?((((0?[13578])|(1[02]))[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\ -\\ /\\ s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\ -\\ /\\ s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))" ;
33+ public static final String _REG_EMAIL = "\\ w+([-+.]\\ w+)*@\\ w+([-.]\\ w+)*\\ .\\ w+([-.]\\ w+)*" ;
34+ public static final String _REG_PHONE = "^[1]([3][0-9]{1}|59|58|88|89)[0-9]{8}$" ;
35+ private static HashMap <String , Pattern > Require_Cache ;
3436
35- static {
36- Require_Cache = new HashMap <String , Pattern >();
37- Require_Cache .put ("_REG_INT" , Pattern .compile (_REG_INT ));
38- Require_Cache .put ("_REG_STRING" , Pattern .compile (_REG_STRING ));
39- Require_Cache .put ("_REG_FLOAT" , Pattern .compile (_REG_FLOAT ));
40- Require_Cache .put ("_REG_DATE" , Pattern .compile (_REG_DATE ));
41- Require_Cache .put ("_REG_EMAIL" , Pattern .compile (_REG_EMAIL ));
42- Require_Cache .put ("_REG_PHONE" , Pattern .compile (_REG_PHONE ));
43- }
37+ static {
38+ Require_Cache = new HashMap <String , Pattern >();
39+ Require_Cache .put ("_REG_INT" , Pattern .compile (_REG_INT ));
40+ Require_Cache .put ("_REG_STRING" , Pattern .compile (_REG_STRING ));
41+ Require_Cache .put ("_REG_FLOAT" , Pattern .compile (_REG_FLOAT ));
42+ Require_Cache .put ("_REG_DATE" , Pattern .compile (_REG_DATE ));
43+ Require_Cache .put ("_REG_EMAIL" , Pattern .compile (_REG_EMAIL ));
44+ Require_Cache .put ("_REG_PHONE" , Pattern .compile (_REG_PHONE ));
45+ }
4446
45- public static boolean require (String require , String value ) {
46- if (Require_Cache .containsKey (require ))
47- return Require_Cache .get (require ).matcher (value ).matches ();
48- Require_Cache .put (require , Pattern .compile (require ));
49- return Require_Cache .get (require ).matcher (value ).matches ();
50- }
47+ public static boolean require (String require , String value ) {
48+ if (Require_Cache .containsKey (require ))
49+ return Require_Cache .get (require ).matcher (value ).matches ();
50+ Require_Cache .put (require , Pattern .compile (require ));
51+ return Require_Cache .get (require ).matcher (value ).matches ();
52+ }
5153
5254}
0 commit comments