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.zilotti.utils.NetworkUtils.java

public static boolean isIpV6(String ipAddress) {
    return (ipAddress.matches(IPV6_REGEX) || (isIpV6_Hex4DecCompressed(ipAddress) || isIpV6_Hex4Dec(ipAddress)
            || isIpV6_HexCompressed(ipAddress)));
}

From source file:Main.java

public static UUID getUUID(String uuid) {
    try {/*from  w  w  w .  j a  v  a2  s  . c  om*/
        return UUID.fromString(uuid);
    } catch (IllegalArgumentException iae) {
        if (uuid.matches("[0-9a-fA-F]{4}")) {
            return UUID.fromString(String.format(BASE_UUID_FORMAT, uuid.toUpperCase()));
        }
    }
    return null;
}

From source file:Main.java

public static boolean validateEmail(EditText editText) {
    if (nonEmpty(editText)) {
        String emailAsString = removeBlankSpace(editText.getText().toString());
        return emailAsString.matches(EMAIL_PATTERN_1) || emailAsString.matches(EMAIL_PATTERN_2);

    } else {//from w  w  w  .  ja  va  2  s  . c o m
        Log.d("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:com.baidu.rigel.biplatform.tesseract.util.String2DateUtils.java

/**
 * /*from   w  ww.  j a v a  2s.  c  o m*/
 * ?
 * @param str 
 * @return DateFormatType
 */
public static DateFormatType dateFormatType(String str) {
    DateFormatType result = null;
    if (!StringUtils.isBlank(str)) {
        if (str.matches("[0-9]*-[0-1][0-9]-[0-3][0-9]")) {
            result = DateFormatType.DATE_FORMAT_YYYY_MM_DD;
        } else if (str.matches("[0-9]*") && str.length() == 8) {
            result = DateFormatType.DATE_FORMAT_YYYYMMDD;
        }

    }
    return result;
}

From source file:org.devdom.commons.util.Utils.java

/**
 * // ww  w  . j av a 2s .  c o  m
 * @param value
 * @return 
 */
public static boolean hasOnlyDigits(String value) {
    return value.matches("[0-9]+");
}

From source file:net.dv8tion.jda.core.entities.Game.java

/**
 * Checks if a given String is a valid Twitch url (ie, one that will display "Streaming" on the Discord client).
 *
 * @param url//from   ww w .ja va2s . c  om
 *      The url to check.
 * @return
 *          boolean
 */
static boolean isValidStreamingUrl(String url) {
    return url != null && url.matches("^https?:\\/\\/(www\\.)?twitch\\.tv\\/.+");
}

From source file:Main.java

public static String parseCustomProxyClassName(String customProxyClassName, String originClassName,
        String targetClassName) {

    mCustomProxyClassName = customProxyClassName;

    String templete = "^(.*)(\\$[O|T])(.*)(\\$[O|T])(.*)$";
    Pattern compile = Pattern.compile(templete);
    Matcher matcher = compile.matcher(mCustomProxyClassName);
    if (!matcher.matches()) {
        printNotMatchErrorMessage();//from  w  ww  .j a v  a 2  s .  co  m
    }

    String group2 = matcher.group(2);
    String group4 = matcher.group(4);
    if (group2.matches("\\$[O]") && group4.matches("\\$[T]")) {
        group2 = originClassName;
        group4 = targetClassName;
    } else if (group2.matches("\\$[T]") && group4.matches("\\$[O]")) {
        group2 = targetClassName;
        group4 = originClassName;
    } else {
        printNotMatchErrorMessage();
    }

    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(matcher.group(1));
    stringBuilder.append(group2);
    stringBuilder.append(matcher.group(3));
    stringBuilder.append(group4);
    stringBuilder.append(matcher.group(5));
    return stringBuilder.toString();
}

From source file:ai.grakn.graql.internal.util.StringConverter.java

private static String escapeLabelOrId(String value) {
    if (value.matches("^[a-zA-Z_][a-zA-Z0-9_-]*$") && !GRAQL_KEYWORDS.contains(value)) {
        return value;
    } else {//from  w w w  .ja  v  a2  s . c o m
        return quoteString(value);
    }
}

From source file:eu.europeana.core.util.web.ControllerUtil.java

public static boolean validEmailAddress(String emailAddress) {
    return emailAddress.matches(EMAIL_REGEXP);
}

From source file:Main.java

public static boolean isMobileNO(String mobiles) {
    String telRegex = "[1][34578]\\d{9}";
    if ("".equals(mobiles))
        return false;
    else//  www.j  a  v a 2  s  . c  o  m
        return mobiles.matches(telRegex);
}