List of usage examples for java.lang String matches
public boolean matches(String regex)
From source file:MainClass.java
public static boolean validateLastName(String lastName) { return lastName.matches("[a-zA-z]+([ '-][a-zA-Z]+)*"); }
From source file:MainClass.java
public static boolean validateFirstName(String firstName) { return firstName.matches("[A-Z][a-zA-Z]*"); }
From source file:GetNumber.java
public static Number process(String s) { if (s.matches(".*[.dDeEfF]")) { try {/*from www .ja v a 2 s. c o m*/ double dValue = Double.parseDouble(s); System.out.println("It's a double: " + dValue); return new Double(dValue); } catch (NumberFormatException e) { System.out.println("Invalid a double: " + s); return NAN; } } else // did not contain . d e or f, so try as int. try { int iValue = Integer.parseInt(s); System.out.println("It's an int: " + iValue); return new Integer(iValue); } catch (NumberFormatException e2) { System.out.println("Not a number:" + s); return NAN; } }
From source file:Main.java
public static boolean isValidMD5(String s) { return s.matches("[a-fA-F0-9]{32}"); }
From source file:Main.java
public static boolean isYouTubeURL(String url) { return url.matches("http[s]://www\\.youtube\\.[a-z]{2,3}(\\.[a-z]{2})?/.*"); }
From source file:Main.java
public static boolean isNum(String str) { return str.matches("^[-+]?(([0-9]+)([.]([0-9]{1,2}))?|([.]([0-9]{1,2}))?)$"); }
From source file:Main.java
public static boolean isNumeric(String str) { return str.matches("-?\\d+(\\.\\d+)?"); //match a number with optional '-' and decimal. }
From source file:Main.java
public static boolean isNumeric(String str) { return str.matches("(-)?\\d*.\\d*(-)?(E)?(-)?\\d*"); //use RegEx to match, can handle SciNo numbers as well }
From source file:Main.java
public static boolean isNumber(String str) { return str.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$"); }
From source file:Main.java
public static boolean isOnlyNum(String str) { return str.matches("[0-9]+"); }