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 isValidEmail(String paramString) {

    String regex = "[a-zA-Z0-9_\\.]{1,}@(([a-zA-z0-9]-*){1,}\\.){1,3}[a-zA-z\\-]{1,}";
    if (paramString.matches(regex)) {
        return true;
    } else {//  www  .  j ava  2 s.  c o  m
        return false;
    }
}

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

static public boolean validateUserName(String userName) {
    return null != userName && userName.matches("[\\x2ea-zA-Z1-90+_-]+");
}

From source file:de.mprengemann.intellij.plugin.androidicons.util.ExportNameUtils.java

public static String getExportNameFromFilename(String filename) {
    String exportName = FilenameUtils.removeExtension(filename);
    if (exportName.matches("[a-z0-9_.]*")) {
        return exportName;
    }//from www  .  j a  v a2 s  .  c o  m
    exportName = exportName.toLowerCase();
    return exportName.replaceAll("([^(a-z0-9_.)])", "_");
}

From source file:Main.java

/**
 * Returns the final word characters after the last '.'
 *//*from w  w  w .j  a  v a 2 s. c o m*/
public static String getFileExtension(String file) {
    int index = file.lastIndexOf('.');
    String extension = "";
    if (index > 0) {
        extension = file.substring(index + 1);
        if (!extension.matches("\\w+")) {
            extension = "";
        }
    }
    return extension;
}

From source file:Main.java

/**
 * Validates if the server-adress is correct (ipv4 || ipv6 || url)
 *
 * @param serverUrl/*w  w  w.j a v  a  2  s .  co m*/
 * @return
 */
public static boolean isValideUrl(String serverUrl) {
    return serverUrl.matches(UrlAndIPRegEx);
}

From source file:org.carewebframework.cal.api.ClientUtil.java

/**
 * For urls without a service root, prepends the default service root.
 * /*  ww  w .j a  v  a  2s  .c o m*/
 * @param url URL to expand.
 * @return URL with a service root prepended.
 */
public static String expandURL(String url) {
    return url.matches("^.+:/") ? url : getServiceRoot() + url;
}

From source file:net.rim.ejde.internal.ui.editors.locale.ResourceKeyValidator.java

private static boolean containsInvalidChar(String key) {
    if (!key.matches("[A-Za-z]{1}[A-Za-z0-9]*([_]{1}[A-Za-z0-9]+)*")) {
        return true;
    }//from  w w w .j a va 2s .  c o  m
    return false;
}

From source file:Main.java

public static boolean isPwd(String pwd) {
    String regex = "^[0-9a-zA-Z]{6,16}$";/* "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$" */
    ;// w w  w. j  av a2 s .  c  o m
    if (!pwd.matches(regex)) {
        return false;
    } else
        return true;
}

From source file:Main.java

public static boolean noSpecialCharacters(EditText editText) {
    if (nonEmpty(editText)) {
        String content = removeBlankSpace(editText.getText().toString());
        return content.matches("[a-zA-Z0-9.? ]*");
    } else {/*from  www.java  2  s .co  m*/
        Log.e("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:cn.edu.zjnu.acm.judge.util.ValueCheck.java

public static void checkEmail(String email) {
    if (!StringUtils.isEmptyOrWhitespace(email) && !email.matches(EMAIL_PATTERN)) {
        throw new MessageException("email format incorrect", HttpStatus.BAD_REQUEST);
    }//w  w w  .  j a v a2  s.  c om
}