List of usage examples for java.util.regex Pattern matches
public static boolean matches(String regex, CharSequence input)
From source file:Main.java
public static boolean isValidTelNumber(String telNumber) { if (!TextUtils.isEmpty(telNumber)) { String regex = "(\\+\\d+)?1[34578]\\d{9}$"; return Pattern.matches(regex, telNumber); }/*w ww.j a v a 2 s . c om*/ return false; }
From source file:Main.java
public static boolean isMobileValid(String mobile) { if (TextUtils.isEmpty(mobile) || !TextUtils.isDigitsOnly(mobile)) { return false; }/*from w w w . j a va 2s.co m*/ return Pattern.matches("^(\\+86)?(1[3-9][0-9])\\d{8}$", mobile); }
From source file:Main.java
public static boolean isValidEmailAddress(String emailAddress) { if (!TextUtils.isEmpty(emailAddress)) { String regex = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; return Pattern.matches(regex, emailAddress); }/*from w ww .j av a 2 s . c o m*/ return false; }
From source file:Main.java
public static boolean isEmailValid(String email) { if (TextUtils.isEmpty(email)) return false; String regex = "^([a-z0-9_\\.-]{1,50})@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$"; return Pattern.matches(regex, email); }
From source file:Main.java
public static boolean isFixPhoneValid(String fixPhone) { if (TextUtils.isEmpty(fixPhone)) return false; String regex = "^(0[0-9]{2,3}\\-)?([2-9][0-9]{6,7})+(\\-[0-9]{1,5})?$"; return Pattern.matches(regex, fixPhone); }
From source file:Main.java
public static boolean isContractNameValid(String name) { if (!TextUtils.isEmpty(name)) { return !Pattern.matches(CONTRACT_NAME_PATTERN, name); }/*from ww w . ja v a 2 s. com*/ return true; }
From source file:Main.java
public static int getNumCores() { try {// w w w. j av a 2 s . c o m File dir = new File("/sys/devices/system/cpu/"); File[] files = dir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return Pattern.matches("cpu[0-9]", pathname.getName()); } }); return files.length; } catch (Exception e) { e.printStackTrace(); return 1; } }
From source file:Main.java
public static int cpuNums() { int nums = 1; try {// ww w. jav a 2s .co m File file = new File("/sys/devices/system/cpu/"); File[] files = file.listFiles(new FileFilter() { @Override public boolean accept(File arg0) { if (Pattern.matches("cpu[0-9]", arg0.getName())) { return true; } return false; } }); nums = files.length; } catch (Exception e) { e.printStackTrace(); } return nums; }
From source file:Main.java
public static int getNumCores() {// Private Class to display only CPU // devices in the directory listing class CpuFilter implements FileFilter { @Override/*from w ww . j av a 2 s . c om*/ public boolean accept(File pathname) { // Check if filename is "cpu", followed by a single digit number if (Pattern.matches("cpu[0-9]", pathname.getName())) { return true; } return false; } } try { // Get directory containing CPU info File dir = new File("/sys/devices/system/cpu/"); // Filter to only list the devices we care about File[] files = dir.listFiles(new CpuFilter()); // Return the number of cores (virtual CPU devices) return files.length; } catch (Exception e) { e.printStackTrace(); // Default to return 1 core return 1; } }
From source file:Main.java
public final static int getNumCores() { // Private Class to display only CPU devices in the directory listing class CpuFilter implements FileFilter { @Override// www . j a va 2 s . c o m public boolean accept(File pathname) { // Check if filename is "cpu", followed by a single digit number if (Pattern.matches("cpu[0-9]", pathname.getName())) { return true; } return false; } } try { // Get directory containing CPU info File dir = new File("/sys/devices/system/cpu/"); // Filter to only list the devices we care about File[] files = dir.listFiles(new CpuFilter()); // Return the number of cores (virtual CPU devices) return files.length; } catch (Exception e) { return Runtime.getRuntime().availableProcessors(); } }