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.esofthead.mycollab.core.utils.StringUtils.java

public static boolean isValidFileName(String value) {
    if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
        return false;
    }/*from  www.java2  s.  co  m*/
    return !value.matches(".*[^\\w -.].*");
}

From source file:org.gytheio.content.transform.options.TemporalSourceOptions.java

/**
 * Validates that the given value is of the form hh:mm:ss[.xxx]
 * /*from  w  ww  .j  a v a  2  s. c  o  m*/
 * @param value
 */
public static void validateTimeString(String value) {
    if (value != null && !value.matches(VALID_TIME_STRING_REGEX)) {
        throw new GytheioRuntimeException(
                "'" + value + "' is not a valid time specification of the form hh:mm:ss[.xxx]");
    }
}

From source file:kr.re.dev.YammaJson.YammaJSON.java

public static <E> List<E> fromJSONArray(Class<E> type, String jsonString, String path) {
    jsonString = jsonString.replace("\n", "");
    boolean isArray = jsonString.matches("^[ |\\t]{0,}[\\[].*[\\]][ |\\t]{0,}$");
    if (isArray) {
        JSONArray jsonArray = new JSONArray(jsonString);
        return fromJSONArray(type, jsonArray);
    } else {/*from w  w  w .j a va  2s  .  co  m*/
        JSONObject jsonObject = new JSONObject(jsonString);
        return fromJSONArray(type, jsonObject, path);
    }
}

From source file:controllers.FileHandler.java

/**
 * brief: parse string from log file to tokens
 * @param strRawString  - string to be tokenized
 * @return              - string list of tokens
 *///from ww w.  j a  v a2  s .  co  m
private static ArrayList<String> ParseLogFile(String strRawString) {
    ArrayList<String> strList = new ArrayList<>();
    strList.clear();

    if (strRawString.matches(".*\\[.*\\].*")) {
        String[] tokens = strRawString.split("\\s*-\\s*");
        strList.add(tokens[0]);
        strList.add(tokens[1]);
    } else {
        strList.add("");
        strList.add(strRawString);
    }

    return strList;
}

From source file:disko.flow.analyzers.XQueryAnalyzer.java

public static boolean isPhone(String text) {
    final boolean matches = text.matches(".*\\({0,1}[0-9]{1,3}[\\)-]{0,1} {0,1}[0-9]{1,3}-[0-9A-Z]{1,4}.*");
    // log.debug("isPhone(\""+text+"\") = "+matches);
    return matches;
}

From source file:cc.gospy.core.util.StringHelper.java

public static boolean isAbsoluteUrl(String url) {
    return url.matches("http://.*|https://.*|//.*");
}

From source file:com.linkedin.cubert.ScriptExecutor.java

private static Map<String, String> extractCubertParams(Properties executorProps) {
    Map<String, String> cubertParams = new HashMap<String, String>();

    int stripLen = CUBERT_PROP_IDENTIFIER.length();
    String regEx = CUBERT_PROP_IDENTIFIER + "*";

    for (String p : executorProps.stringPropertyNames()) {
        if (!p.matches(regEx))
            continue;

        String key = p.substring(stripLen, p.length());
        String value = executorProps.getProperty(p);

        cubertParams.put(key, value);/*from w ww. ja va 2s  .  c o m*/
    }

    return cubertParams;
}

From source file:Main.java

public static boolean isMobile(String mobiles) {
    String telRegex = "(13[0-9]|14[57]|15[012356789]|17[0123456789]|18[0123456789])\\d{8}";

    //Pattern p = Pattern
    //        .compile("^((13[0-9])|(15[^4,//D])|(18[0,5-9]))//d{8}$");
    //Matcher m = p.matcher(mobiles);
    return !mobiles.matches(telRegex);
}

From source file:alluxio.util.io.PathUtils.java

/**
 * Determines whether the given path is a temporary file name generated by Alluxio.
 *
 * @param path the path to check//from ww  w .  ja  v  a2s  . c o  m
 * @return whether the given path is a temporary file name generated by Alluxio
 */
public static boolean isTemporaryFileName(String path) {
    return path.matches("^.*\\.alluxio\\.0x[0-9A-F]{16}\\.tmp$");
}

From source file:com.ocs.dynamo.utils.DateUtils.java

/**
 * Translates a week code (yyyy-ww) to the starting day (this is taken to be a Monday) of that
 * week/*from w  w  w .jav a 2  s . co m*/
 * 
 * @param weekCode
 * @return
 */
public static Date getStartDateOfWeek(String weekCode) {
    if (weekCode != null && weekCode.matches(WEEK_CODE_PATTERN)) {
        int year = getYearFromWeekCode(weekCode);
        int week = getWeekFromWeekCode(weekCode);

        Calendar calendar = new GregorianCalendar(DynamoConstants.DEFAULT_LOCALE);
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.WEEK_OF_YEAR, week);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

        return truncate(calendar).getTime();
    }
    return null;
}