Example usage for java.util.regex Pattern matches

List of usage examples for java.util.regex Pattern matches

Introduction

In this page you can find the example usage for java.util.regex Pattern matches.

Prototype

public static boolean matches(String regex, CharSequence input) 

Source Link

Document

Compiles the given regular expression and attempts to match the given input against it.

Usage

From source file:Main.java

public static boolean verifyPhoneNumber(String phoneNumber) {
    return Pattern.matches("^1[358][0-9]{9}$", phoneNumber);
}

From source file:Main.java

public static boolean checkDigitInt(String digit) {
    String patrn = "^[+]?\\d+$";
    return Pattern.matches(patrn, digit);
}

From source file:Main.java

public static boolean checkDigit(String digit) {
    String regex = "^[-\\+]?\\d+$";
    return Pattern.matches(regex, digit);
}

From source file:Main.java

public static boolean checkMobile11(String mobile) {
    String regex2 = "^[0-9]{11}$";
    return Pattern.matches(regex2, mobile);
}

From source file:Main.java

private static boolean isDouble(String number) {
    return Pattern.matches("\\d+\\.\\d+", number);
}

From source file:Main.java

public static boolean chechHTML(String str) {
    String regex = "<(S*?)[^>]*>.*?|<.*? />";
    return Pattern.matches(regex, str);
}

From source file:Main.java

public static boolean verifyName(String name) {
    String regex = "^[a-zA-Z]+[a-zA-Z0-9_]*$";
    return Pattern.matches(regex, name);
}

From source file:Main.java

public static boolean isSubDirectory(File sourceLocation, File targetLocation) {
    return Pattern.matches(sourceLocation.getAbsolutePath() + ".*", targetLocation.getAbsolutePath());
}

From source file:Main.java

public static boolean checkMobile(String mobile) {
    String regex = "(\\+\\d+)?1[3458]\\d{9}$";
    return Pattern.matches(regex, mobile);
}

From source file:Main.java

public static boolean isValidKeyWord(String value) {
    String regex = "^[a-zA-Z0-9-]{6,20}+$";
    return Pattern.matches(regex, value);
}