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:com.crossover.trial.weather.domain.IATA.java

public static IATA valueOf(String code) {
    Assert.hasText(code, "iata code is required");
    Assert.isTrue(code.matches("[a-zA-Z]{3}"), "iata must be a 3-letter code");
    return new IATA(code);
}

From source file:Main.java

public static boolean isValidXmlFile(final File file) {
    boolean result;

    try {//from w  w  w  .j  av  a 2s  . c o  m
        final InputStream input = new FileInputStream(file.getPath());
        final byte[] header = new byte[32];
        input.read(header, 0, 32);

        String headerStr = new String(header, "ASCII");
        String XML_REGEX = "^\\s*<(\\?|!(--)?)?\\s*\\w+.*";

        result = headerStr.matches(XML_REGEX);

        try {
            input.close();
        } catch (Exception e) {
            // ignore this exception
        }
    } catch (Exception e) {
        result = false;
    }

    return result;

}

From source file:org.mobile.mpos.util.Common.java

/**
 * ??// w  w  w. jav  a2s .c  o  m
 * @param mobile
 * @return
 */
public static boolean isMobile(String mobile) {
    if (StringUtils.isBlank(mobile)) {
        return false;
    }
    return mobile.matches("^1[34578][0-9]{9}$");
}

From source file:io.lavagna.web.security.SecurityFilter.java

private static boolean canApplyNoCachingHeaders(HttpServletRequest req) {
    String u = req.getRequestURI();
    return !("/".equals(u) || u.matches(".*\\.(css|gif|js|png|html|eot|svg|ttf|woff)$"));
}

From source file:Main.java

public static boolean isMail(String str) {
    if (isEmpty(str))
        return false;
    String mailRegex = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
    Boolean b = str.matches(mailRegex);
    return b;/*from  w w  w . jav  a2s . c  o  m*/
}

From source file:Main.java

public static boolean checkVerifyCode(String verifyCode) {
    if (TextUtils.isEmpty(verifyCode)) {
        return false;
    } else {/* w  w  w.  j  av  a 2s . co  m*/
        String verRegex = "[0-9]{6}";
        return verifyCode.matches(verRegex);

    }
}

From source file:com.p000ison.dev.copybooks.util.Helper.java

public static boolean isDecimal(String test) {
    return test.matches("\\d+(\\.\\d{1,6})?");
}

From source file:net.lmxm.ute.executers.tasks.subversion.SubversionUtils.java

/**
 * Checks if is revision date.// w w w  . ja v a  2s . co m
 * 
 * @param revision the revision
 * @return true, if is revision date
 */
public static boolean isRevisionDate(final String revision) {
    return revision != null && revision.matches("\\{\\d{4}-\\d{2}-\\d{2}\\}");
}

From source file:net.lmxm.ute.executers.tasks.subversion.SubversionUtils.java

/**
 * Checks if is revision number./*from  w  w w .j a  va2  s  .c o m*/
 * 
 * @param revision the revision
 * @return true, if is revision number
 */
public static boolean isRevisionNumber(final String revision) {
    return revision != null && revision.matches("(0)|([1-9][0-9]+)");
}

From source file:Main.java

public static boolean isEmail(String messageStr) {
    String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    return messageStr.matches(str);
}