List of usage examples for java.lang String matches
public boolean matches(String regex)
From source file:edu.duke.cabig.c3pr.utils.StringUtils.java
public static boolean isValidEmail(String email) { return email.matches(".+@.+\\.[a-zA-Z]+"); }
From source file:edu.duke.cabig.c3pr.utils.StringUtils.java
public static boolean isValidPhone(String phone) { return phone.matches( "^(1\\s*[-\\/\\.]?)?(\\((\\d{3})\\)|(\\d{3}))\\s*[-\\/\\.]?\\s*(\\d{3})\\s*[-\\/\\.]?\\s*(\\d{4})\\.?\\-?\\s*(([xX]|[eE][xX][tT])\\.?\\-?\\s*(\\d+))*$"); }
From source file:edu.duke.cabig.c3pr.utils.StringUtils.java
public static boolean isValidFax(String phone) { return phone.matches( "^(1\\s*[-\\/\\.]?)?(\\((\\d{3})\\)|(\\d{3}))\\s*[-\\/\\.]?\\s*(\\d{3})\\s*[-\\/\\.]?\\s*(\\d{4})\\s*"); }
From source file:com.cloudera.sqoop.shims.ShimLoader.java
/** * Look through the shim directory for a jar matching 'jarPattern' * and classload it.//w ww . j a va2s .c o m * @param jarPattern a regular expression which the shim jar's filename * must match. * @param className a class to classload from the jar. */ private static void loadMatchingShimJar(String jarPattern, String className) throws IOException { String jarFilename; String shimDirName = System.getProperty(SHIM_JAR_DIR_PROPERTY, "."); File shimDir = new File(shimDirName); if (!shimDir.exists()) { throw new IOException("No such shim directory: " + shimDirName); } String[] candidates = shimDir.list(); if (null == candidates) { throw new IOException("Could not list shim directory: " + shimDirName); } for (String candidate : candidates) { if (candidate.matches(jarPattern)) { LOG.debug("Found jar matching pattern " + jarPattern + ": " + candidate); File jarFile = new File(shimDir, candidate); String jarFileName = jarFile.toString(); ClassLoaderStack.addJarFile(jarFileName, className); LOG.debug("Successfully pushed classloader for jar: " + jarFileName); return; } } throw new IOException("Could not load shim jar for pattern: " + jarPattern); }
From source file:playground.thibautd.analysis.populationstats.PlotCliqueSizeDistribution.java
private static List<Integer> getSizeInfo(final BufferedReader reader) { List<Integer> sizes = new ArrayList<Integer>(); try {/* www . ja v a 2 s . co m*/ String line = reader.readLine(); int count = 0; while (line != null) { //log.debug(line); if (line.matches(START_CLIQUE)) { if (count != 0) { throw new RuntimeException("opening a new clique before " + "closing the previous one."); } } else if (line.matches(PERSON_DEF)) { count++; } else if (line.matches(END_CLIQUE)) { sizes.add(count); count = 0; } line = reader.readLine(); } } catch (IOException e) { throw new RuntimeException(e); } return sizes; }
From source file:com.eho.dynamodb.DynamoDBConnection.java
private static int create_new_version_numbe_old(Item item) throws Exception { JSONObject json_resource = new JSONObject(item.toJSONPretty()); Iterator<String> itr = json_resource.keys(); int max_version = Integer.MIN_VALUE; while (itr.hasNext()) { String nextString = itr.next(); if (nextString.matches("[0-9]+"))//if a ltter does not exist in the key.this means it is a version of the rseource {//w ww . j a va 2 s.co m int thisValue = Integer.valueOf(nextString); if (thisValue > max_version) max_version = thisValue; } } if (max_version == Integer.MIN_VALUE) return 0; else return ++max_version; }
From source file:com.hoccer.tools.TestHelper.java
public static void assertMatches(String message, String regexp, String measured) { if (!measured.matches(regexp)) { Assert.fail(message + " but '" + regexp + "' does not match '" + measured + "'"); }/*from w w w.j a v a2 s . c o m*/ }
From source file:com.evolveum.midpoint.util.QNameUtil.java
public static boolean isUri(String string) { if (string == null) { return false; }// w w w . ja va2 s .c om return string.matches("^\\w+:.*"); }
From source file:com.microsoftopentechnologies.windowsazurestorage.helper.Utils.java
/** * This method checks if text contains tokens in the form of $TOKEN or * ${TOKEN}// w w w .j a va 2 s . c o m * * @param text * @return true if tokens exist in input string */ public static boolean containTokens(String text) { if (StringUtils.isBlank(text)) { return false; } return text.matches(Constants.TOKEN_FORMAT); }
From source file:MatchAddress.java
public static boolean isAddressValid(String addr) { boolean retval = false; String nameToken = "\\p{Upper}(\\p{Lower}+\\s?)"; String namePattern = "(" + nameToken + "){2,3}"; String zipCodePattern = "\\d{5}(-\\d{4})?"; String addressPattern = "^" + namePattern + "\\w+ .*, \\w+ " + zipCodePattern + "$"; retval = addr.matches(addressPattern); String msg = "NO MATCH\npattern:\n " + addr + "\nregexLength:\n " + addressPattern; if (retval) { msg = "MATCH\npattern:\n " + addr + "\nregexLength:\n " + addressPattern; }//from w ww .j a v a2s . c om System.out.println(msg + "\r\n"); return retval; }