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 String translate(String name) {
    if (name.matches("qtp.*acceptor-.*-ServerConnector.*")) {
        return "Jetty Acceptor";
    }/*  ww w . j  a  va  2s  . co  m*/
    if (name.matches("qtp.*selector.*")) {
        return "Jetty Selector";
    }
    if (name.matches("qtp\\d+-\\d+")) {
        return "Queued Thread Pool (no name)";
    }
    if (name.matches("Timer-\\d+")) {
        return "Timer (no name)";
    }
    if (name.matches("New Relic .*")) {
        return "New Relic";
    }
    if (name.matches("pool-\\d+-thread-\\d+")) {
        return "Thread Pool (no name)";
    }
    return name.replace("-+", " ").replace("\\d+", " ").replace("\\s+", " ");
}

From source file:Main.java

private static boolean matchPattern(String s, String pattern) {
    return s.matches(pattern);
}

From source file:Main.java

/**
 * Validates the user full name.//from   w w w .  j a  va2s.c om
 * @param fullname - User full name.
 * @return - True (if is valid) or False (otherwise).
 */
public static boolean validateFullName(String fullname) {
    if (fullname == null || !fullname.matches("^[A-Za-z]{3,}(\\s[A-Za-z]+[\\.]{0,1})+[ ]*"))
        return false;

    return true;
}

From source file:Main.java

public static String insideTopLevel(String xpath) {
    boolean alreadyInsideTopLevel = xpath.matches("^[(]*[//]+.*");

    final String prefix = (alreadyInsideTopLevel) ? "" : (xpath.startsWith("(")) ? "(//" : "//";
    final int chopn = (xpath.startsWith("(") && !alreadyInsideTopLevel) ? 1 : 0;
    return prefix + xpath.substring(chopn);
}

From source file:Main.java

public static Map<String, Object> getMapValueSubset(Map<String, Object> list, String pattern) {
    HashMap<String, Object> result = new HashMap<>();

    for (String key : list.keySet()) {
        if (key.matches(pattern)) {
            result.put(key, list.get(key));
        }//from w ww.  jav  a  2 s .c o m
    }

    return result;
}

From source file:Main.java

public static boolean isValid_num(String str) {
    String regex = "\\d{8,12}";
    return str.matches(regex);
}

From source file:Main.java

public static boolean isPwd(String str) {
    boolean result = false;
    result = str.matches("^[0-9a-zA-Z][\\~!@#$%^&*()_+-={}\\[\\]?/,.]{6,12}$");
    return result;
}

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

public static boolean isGuestEmail(String email) {
    return email.matches("guest_[0123456789]+");
}

From source file:Main.java

public static boolean isPostalcode(String str) {
    String regex = "^\\d{6}$";
    return str.matches(regex);
}

From source file:Main.java

public static boolean checkIsZH(String input) {
    char[] charArray = input.toLowerCase().toCharArray();
    for (char c : charArray) {
        String tempC = Character.toString(c);
        if (tempC.matches("[\u4E00-\u9FA5]+")) {
            return true;
        }//from   ww  w .  j a va2 s  .c  o m
    }
    return false;
}