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 isMobileNO(String mobiles) {

    String telRegex = "[1][123456789]\\d{9}";
    if (isNull(mobiles))
        return false;
    else/*ww  w. j  av  a 2s .  c  om*/
        return mobiles.matches(telRegex);
}

From source file:com.collabnet.svnedge.net.CommonsHTTPProxySender.java

static boolean isRepositoryHttps(String repositoryUrl) {
    return repositoryUrl.matches("https.*");
}

From source file:net.commerce.zocalo.user.SecureUser.java

static public boolean validatePassword(String passwd) {
    return null != passwd && passwd.length() >= 7
            && passwd.matches("\\p{Graph}*[\\p{Digit}\\p{Punct}]\\p{Graph}*");
}

From source file:com.Module.RegisterModule.java

public static boolean checkEmail(String email) {
    if (!email.matches("[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+")) {
        return false;
    }/*from  w w  w . j  a  va2s  .com*/

    String host = "";
    String hostName = email.split("@")[1];
    Record[] result = null;
    SMTPClient client = new SMTPClient();

    try {
        // MX
        Lookup lookup = new Lookup(hostName, Type.MX);
        lookup.run();
        if (lookup.getResult() != Lookup.SUCCESSFUL) {
            return false;
        } else {
            result = lookup.getAnswers();
        }

        // ?
        for (int i = 0; i < result.length; i++) {
            host = result[i].getAdditionalName().toString();
            client.connect(host);
            if (!SMTPReply.isPositiveCompletion(client.getReplyCode())) {
                client.disconnect();
                continue;
            } else {
                break;
            }
        }

        //2
        client.login("qq.com");
        client.setSender("526199427@163.com");
        client.addRecipient(email);
        if (250 == client.getReplyCode()) {
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            client.disconnect();
        } catch (IOException e) {
        }
    }
    return false;
}

From source file:com.polytech4A.cuttingstock.core.resolution.util.context.ContextLoaderUtils.java

/**
 * Line Parser of global first infomrations.
 *
 * @param iterator iterator of the openfile.
 * @param regex    regex of the line.//from  w ww. j a v a  2 s . c o  m
 * @return value loaded.
 * @throws MalformedContextFileException if the Context file don't have the right structure.
 */
private static Double loadLine(LineIterator iterator, String regex) throws MalformedContextFileException {
    MalformedContextFileException mctx = new MalformedContextFileException();
    if (iterator.hasNext()) {
        String line = iterator.nextLine();
        if (line.matches(regex)) {
            return Double.parseDouble(line.split("=")[1]);
        } else {
            throw mctx;
        }
    } else {
        throw mctx;
    }
}

From source file:com.xc.xnode.utils.StringUtils.java

public static boolean isDBStrictChar(String value) {
    return isBlank(value) ? false : value.matches(DB_STRICT_CHAR_REG);
}

From source file:Main.java

public static boolean personIdValidation(String text) {
    boolean flag = false;
    String regx = "[0-9]{17}x";
    String reg1 = "[0-9]{15}";
    String regex = "[0-9]{18}";
    flag = text.matches(regx) || text.matches(reg1) || text.matches(regex);
    return flag;//www .  jav a2 s .  c  o m
}

From source file:Main.java

public static boolean isMobiPhoneNumber(String telNum) {
    if (TextUtils.isEmpty(telNum)) {
        return false;
    }/* ww w .  ja  va2  s. c o m*/
    telNum = telNum.replaceAll("^\\+{0,1}86", "");

    return telNum.matches("^((13[0-9])|(15[0-9])|(17[0-9]))|(18[0-9]))\\d{8}$");
}

From source file:Main.java

/**   Check that string contains valid XML characters.
 *
 *   @param   xml      The XML text to check.
 *
 *   @return         true if the string contains only characters
 *               valid in XML, false otherwise.
 *///from  www .j ava  2 s  .  co  m

public static boolean iSValidXMLText(String xml) {
    boolean result = true;

    if (xml != null) {
        result = xml.matches(
                //# ASCII

                "^([\\x09\\x0A\\x0D\\x20-\\x7E]|" +

                //# non-overlong 2-byte

                        "[\\xC2-\\xDF][\\x80-\\xBF]|" +

                        //# excluding overlongs

                        "\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|" +

                        //# straight 3-byte

                        "[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|" +

                        //# excluding surrogates

                        "\\xED[\\x80-\\x9F][\\x80-\\xBF]|" +

                        //# planes 1-3

                        "\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|" +

                        //# planes 4-15

                        "[\\xF1-\\xF3][\\x80-\\xBF]{3}|" +

                        //# plane 16

                        "\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$");
    }

    return result;
}

From source file:Main.java

public static boolean isValidEmailAddress(String mailAddress) {
    String regExp = "^[A-Za-z0-9](([_\\.\\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\\.\\-]?[a-zA-Z0-9]+)*)\\.([A-Za-z]{2,})$";
    boolean isValid = mailAddress.matches(regExp);
    return isValid;
}