List of usage examples for java.util.regex Matcher matches
public boolean matches()
From source file:com.cy.common.util.ValidateUtil.java
/** * ???//from ww w. java2 s .com * @return false:?; true: * */ public static boolean validateIdentityLicenseNum(String identityLicenseNum) { if (StringUtils.isEmpty(identityLicenseNum)) { return false; } Pattern pattern = Pattern .compile("^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])((\\d{4})|\\d{3}[A-Z])$"); Matcher macher = pattern.matcher(identityLicenseNum); return macher.matches(); }
From source file:Main.java
public static Boolean isMobileNo(String str) { Boolean isMobileNo = false;/* w w w . j a va2 s . com*/ try { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(str); isMobileNo = m.matches(); } catch (Exception e) { e.printStackTrace(); } return isMobileNo; }
From source file:Main.java
public static float getSize(String size) { float value = 15.0f; if (size != null) { Matcher m = SIZED_VALUE.matcher(size.trim()); if (m.matches()) { value = Float.parseFloat(m.group(1)); }/*from w ww. j a v a2 s. c o m*/ } return value; }
From source file:Main.java
public static Boolean isMobileNo(String str) { Boolean isMobileNo = false;//from w w w .ja va 2s .co m try { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-9])|(14[0-9])|(17[0-9]))\\d{8}$"); Matcher m = p.matcher(str); isMobileNo = m.matches(); } catch (Exception e) { e.printStackTrace(); } return isMobileNo; }
From source file:Main.java
public static String getDomain(String target) { Pattern p = Pattern.compile(".*?([^.]+\\.[^.]+)"); URI uri;/* w ww .j ava 2s .co m*/ try { uri = new URI(target); } catch (Exception e) { return "http"; } String host = uri.getHost(); Matcher m = p.matcher(host); if (m.matches()) return m.group(1); else return host; }
From source file:Main.java
public static Boolean isMobileNo(String str) { Boolean isMobileNo = false;//from w w w. ja va 2 s .co m try { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-9])|(17[0-9]))\\d{8}$"); Matcher m = p.matcher(str); isMobileNo = m.matches(); } catch (Exception e) { e.printStackTrace(); } return isMobileNo; }
From source file:Main.java
public static Boolean isMobileNo(String str) { Boolean isMobileNo = false;/*from w w w . java2 s . c om*/ try { Pattern p = Pattern.compile("^1[3,4,5,7,8]\\d{9}$"); Matcher m = p.matcher(str); isMobileNo = m.matches(); } catch (Exception e) { e.printStackTrace(); } return isMobileNo; }
From source file:Main.java
public static boolean validateIPAddress(String ip) { if (ip == null || ip.isEmpty()) return false; ip = ip.trim();// w w w. java2 s . com if ((ip.length() < 6) & (ip.length() > 15)) return false; try { Pattern pattern = Pattern.compile( "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); Matcher matcher = pattern.matcher(ip); return matcher.matches(); } catch (PatternSyntaxException ex) { return false; } }
From source file:Main.java
public static Boolean isMobileNo(String str) { Boolean isMobileNo = false;// w w w . j a v a 2 s . c om try { Pattern p = Pattern.compile("^((13[0-9])|(15[0-9])|(18[0-9]))\\d{8}$"); Matcher m = p.matcher(str); isMobileNo = m.matches(); } catch (Exception e) { e.printStackTrace(); } return isMobileNo; }
From source file:Main.java
public static Boolean isIDCard(String str) { Boolean isIDCard = false;// w w w . j a v a 2s . c om try { Pattern p = Pattern.compile( "^[1-9][0-9]{5}(19[0-9]{2}|200[0-9]|2010)(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])[0-9]{3}[0-9xX]$"); Matcher m = p.matcher(str); isIDCard = m.matches(); } catch (Exception e) { e.printStackTrace(); } return isIDCard; }