Example usage for java.lang String matches

List of usage examples for java.lang String matches

Introduction

In this page you can find the example usage for java.lang String matches.

Prototype

public boolean matches(String regex) 

Source Link

Document

Tells whether or not this string matches the given regular expression.

Usage

From source file:Main.java

public static boolean isPhoneNum(String num) {
    String dex = "^((13[0-9])|(15[^4,\\D])|(17[0-9])|(18[0-9]))\\d{8}$";
    return num.matches(dex);
}

From source file:Main.java

private static String getUnclosedTagWithSubstring(String text) {
    if (text.length() == 0) {
        return "";
    } else if (text.matches("^.*(<[a-zA-Z]*>)$")) {
        return text;
    } else if (text.matches("^.*(</[a-zA-Z]*>)$")) {
        return "";
    } else {//from w  w  w  .  j  a  va 2 s.c  o  m
        return getUnclosedTagWithSubstring(text.substring(0, text.length() - 1));
    }
}

From source file:Main.java

public static Float testNumber(String aArg) {
    while (true) {
        if (aArg.length() == 0) {
            return null;
        }//from  w w w. j  av a 2  s .co m
        if (aArg.matches("-?\\d+(\\.\\d+)?") == true) {
            break;
        } else {
            throw new IllegalArgumentException("not a number");
        }
    }
    return Float.parseFloat(aArg);
}

From source file:Main.java

public static final boolean isIdCard(String str) {
    if (isBlank(str)) {
        return false;
    }/*from w w w  .  j a va2  s. c om*/

    return str.matches("[0-9]{17}X") || str.matches("[0-9]{18}");
}

From source file:Main.java

public static boolean isChar(String fstrData) {
    String regPw = "/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,15}$/";
    return fstrData.matches(regPw);
}

From source file:Main.java

public static boolean isEmailValid(String email) {
    String regex = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
    return email.matches(regex);
}

From source file:classes.InputCheck.java

public static Boolean checkBookISBN(String inputtxt) {
    return inputtxt.matches("(([0-9Xx][- ]*){13}|([0-9Xx][- ]*){10})") && checkStringIsNotBlank(inputtxt);
}

From source file:classes.InputCheck.java

public static Boolean checkBookISBN_NotMandatory(String inputtxt) {
    return inputtxt.matches("(([0-9Xx][- ]*){13}|([0-9Xx][- ]*){10})") || !checkStringIsNotBlank(inputtxt);
}

From source file:classes.InputCheck.java

public static Boolean checkPublisherISBN(String inputtxt) {
    return inputtxt.matches("(([0-9Xx][- ]*){5,7})") && checkStringIsNotBlank(inputtxt);
}

From source file:classes.InputCheck.java

public static Boolean checkPublisherISBN_NotMandatory(String inputtxt) {
    return inputtxt.matches("(([0-9Xx][- ]*){5,7})") || !checkStringIsNotBlank(inputtxt);
}