List of usage examples for java.lang String matches
public boolean matches(String regex)
From source file:io.mindmaps.graql.internal.StringConverter.java
/** * @param id an id of a concept/*from w w w . jav a 2s .c o m*/ * @return * The id of the concept correctly escaped in graql. * If the ID doesn't begin with a number and is only comprised of alphanumeric characters, underscores and dashes, * then it will be returned as-is, otherwise it will be quoted and escaped. */ public static String idToString(String id) { if (id.matches("^[a-zA-Z_][a-zA-Z0-9_-]*$")) { return id; } else { return quoteString(id); } }
From source file:MatchDates.java
public static boolean isDateValid(String date) { boolean retval = false; String datePattern = "\\d{1,2}-\\d{1,2}-\\d{4}"; retval = date.matches(datePattern); String msg = "NO MATCH: pattern:" + date + "\r\n regexLength: " + datePattern; if (retval) { msg = "MATCH : pattern:" + date + "\r\n regexLength: " + datePattern; }/*from ww w.ja va2 s. co m*/ System.out.println(msg + "\r\n"); return retval; }
From source file:Main.java
public static final boolean isPwd(String str) { if (isBlank(str)) { return false; }//from w ww . java 2 s .c o m return str.matches("^[a-zA-Z]\\w{6,30}$"); }
From source file:Main.java
public static final boolean isEmail(String str) { if (isBlank(str)) { return false; }//w w w . jav a 2 s . c o m return str.matches("^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]+[.a-zA-Z]+$"); }
From source file:Main.java
public static boolean isRCIDMatches(String rcId) { rcId = rcId.trim();// ww w . j av a 2 s .c o m int textLength = rcId.length(); return rcId.matches(RCID_REGEX) && textLength >= RCID_MIN_LENGTH && textLength <= RCID_MAX_LENGTH; }
From source file:Main.java
public static boolean isWholeNumber(String string) { if (string != null && !string.trim().isEmpty()) { return string.matches("\\d*"); }// w ww . j av a2s . co m else { return false; } }
From source file:Main.java
public static final boolean isIconUrl(String str) { if (isBlank(str)) { return false; }//from w ww. j av a 2 s .c o m return str.matches( "((http|https|ftp|rtsp|mms):(\\/\\/|\\\\\\\\){1}((\\w)+[.]){1,}(net|com|cn|org|cc|tv|[0-9]{1,3})(\\S*\\/)((\\S)+[.]{1}(gif|jpg|png|bmp)))"); }
From source file:Main.java
public static String matchCamelCase(String query, String str) { if (!query.matches("[A-Za-z\\*]+")) { return null; }//from w w w . ja v a 2s.co m String head = ""; int i; for (i = 0; i < query.length(); i++) { char charI = query.charAt(i); if (Character.isLowerCase(charI)) { head += charI; } else { break; } } if (i > 0) { head += "[^A-Z]*"; } String tail = query.substring(i); String re = "\\b("; tail = tail.replaceAll("\\*", ".*?"); re += head + tail.replaceAll("([A-Z][^A-Z]*)", "$1[^A-Z]*"); re += ".*?)\\b"; Pattern regex = Pattern.compile(re); Matcher m = regex.matcher(str); if (m.find()) { return m.group(); } else { return null; } }
From source file:com.bsb.intellij.plugins.xmlbeans.utils.ValidationUtils.java
public static boolean isValidRelativePath(String path) { return StringUtils.isNotBlank(path) && path.matches(RELATIVE_PATH_REGEX); }
From source file:Main.java
public static String getMacFromArpCache(String ip) { if (ip == null) return null; BufferedReader br = null;// w w w. jav a 2 s. co m try { br = new BufferedReader(new FileReader("/proc/net/arp")); String line; while ((line = br.readLine()) != null) { String[] splitted = line.split(" +"); if (splitted != null && splitted.length >= 4 && ip.equals(splitted[0])) { // Basic sanity check String mac = splitted[3]; if (mac.matches("..:..:..:..:..:..")) { return mac; } else { return null; } } } } catch (Exception e) { e.printStackTrace(); } finally { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } return null; }