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 isRealNumber(String paramString) {
    String regex = "^(0|[1-9][0-9]*)(\\.[0-9]+)?$";
    if (paramString.matches(regex)) {
        return true;
    } else {//from  w ww .  j  a v a  2s  . c  om
        return false;
    }
}

From source file:Main.java

public final static boolean isShellFriendly(CharSequence s) {
    String str = s instanceof String ? (String) s : s.toString();
    return str.matches("^[a-zA-Z0-9_]+$");
}

From source file:Main.java

public final static boolean isShellFriendlyPath(CharSequence s) {
    String str = s instanceof String ? (String) s : s.toString();
    return str.matches("^[/a-zA-Z0-9_.]+$");
}

From source file:Main.java

public static String getStringByLength(String string, int length) {
    StringBuffer stringBuffer = new StringBuffer();

    int valueLength = 0;
    String chinese = "[\u4e00-\u9fa5]";

    for (int i = 0; i < string.length(); i++) {

        String temp = string.substring(i, i + 1);
        if (temp.matches(chinese)) {
            if (valueLength >= (length - 1))
                break;
            valueLength += 2;/*from   w ww .  j a  v a  2 s . co  m*/

        } else {
            if (valueLength >= length)
                break;
            valueLength += 1;

        }
        stringBuffer.append(temp);
    }
    return stringBuffer.toString();
}

From source file:Main.java

/** Determines if the passed value is a binary string of 64 bits
 *  @param value the binary string// ww  w. j  a  v  a 2  s .com
 *  @return a boolean value*/
public static boolean is64BinaryString(String value) {
    if (value.length() == 64 && value.matches("[01]{64}")) {
        return true;
    }

    return false;
}

From source file:pl.bristleback.server.bristle.conf.resolver.action.ActionResolvingUtils.java

private static void validateActionNameFromAnnotationValue(String actionName) {
    if (!actionName.matches(ALLOWED_ACTION_NAME_PATTERN)) {
        throw new BristleInitializationException(
                "Action name must match pattern \"" + ALLOWED_ACTION_NAME_PATTERN + "\"");
    }/*w  w w .ja v a 2 s .com*/
}

From source file:Main.java

public static int strLength(String str) {
    int valueLength = 0;
    String chinese = "[\u0391-\uFFE5]";
    if (!isEmpty(str)) {
        for (int i = 0; i < str.length(); i++) {
            String temp = str.substring(i, i + 1);
            if (temp.matches(chinese)) {
                valueLength += 2;/*from  w  ww . ja  va  2  s.c  o  m*/
            } else {
                valueLength += 1;
            }
        }
    }
    return valueLength;
}

From source file:Main.java

public static Boolean isContainChinese(String str) {
    Boolean isChinese = false;//  ww w .j av  a2s.co m
    String chinese = "[\u0391-\uFFE5]";
    if (!isEmpty(str)) {
        for (int i = 0; i < str.length(); i++) {
            String temp = str.substring(i, i + 1);
            isChinese = temp.matches(chinese);
        }
    }
    return isChinese;
}

From source file:Main.java

public static Boolean isChinese(String str) {
    Boolean isChinese = true;/*from w w w  .j a v a2s  .  co m*/
    String chinese = "[\u0391-\uFFE5]";
    if (!isEmpty(str)) {
        for (int i = 0; i < str.length(); i++) {
            String temp = str.substring(i, i + 1);
            isChinese = temp.matches(chinese);
        }
    }
    return isChinese;
}

From source file:es.uvigo.ei.sing.gc.utils.Validator.java

public static boolean isPassword(String password) {
    return Validator.isNotEmpty(password) && password.matches(Validator.PASSWORD_PATTERN);
}