List of usage examples for java.util.regex Matcher matches
public boolean matches()
From source file:commonUtils.CommonUtils.java
public static boolean IsValidEmailAddress(String emailAddress) { String expression = "^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"; CharSequence inputStr = emailAddress; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); return matcher.matches(); }
From source file:com.wisemapping.validator.Utils.java
static boolean isValidateEmailAddress(@Nullable final String email) { boolean result = false; if (email != null) { //Match the given string with the emailPattern final Matcher m = emailPattern.matcher(email); //check whether match is found result = m.matches(); }/*from w ww .j ava2 s. co m*/ return result; }
From source file:com.google.gdt.eclipse.designer.hosted.tdt.Utils.java
/** * Lookup for "gwt-user.jar" entry; it can be "gwt-user-1.5.3.jar", so use regexp. *//*from www. j a v a 2 s .c om*/ private static String getUserJarLocation(List<String> locations) { Pattern p = Pattern.compile(".*gwt-user.*\\.jar"); for (String location : locations) { Matcher m = p.matcher(location); if (m.matches()) { return location; } } return null; }
From source file:com.google.gdt.eclipse.designer.hosted.tdt.Utils.java
/** * Lookup for "gwt-dev.jar" entry; it can be "gwt-dev-1.5.3.jar", so use regexp. *//* w w w . ja v a2 s . co m*/ private static String getDevJarLocation(List<String> locations) { Pattern p = Pattern.compile(".*gwt-dev.*\\.jar"); for (String location : locations) { Matcher m = p.matcher(location); if (m.matches()) { return location; } } return null; }
From source file:edu.htl3r.schoolplanner.DateTimeUtils.java
/** * Wandelt einen {@link #toISO8601Date(DateTime)}-String in ein DateTime-Objekt um. * @param dateString String, der umgewandelt werden soll * @return Das initialisierte {@link DateTime}-Objekt * @throws ParseException Falls der String nicht geparst werden kann *//*from w w w . j a v a 2 s .co m*/ public static DateTime iso8601StringToDateTime(String dateString) throws ParseException { Pattern p = Pattern.compile("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$"); Matcher m = p.matcher(dateString); if (m.matches()) { DateTime dateTime = new DateTime(); dateTime.set(Integer.parseInt(m.group(3)), Integer.parseInt(m.group(2)), Integer.parseInt(m.group(1))); return dateTime; } throw new ParseException("Unable to parse String " + dateString + " to date."); }
From source file:org.syphr.mythtv.ws.impl.ServiceUtils.java
public static String getVersion(URI serviceBaseUri) throws IOException { URI uri = URI.create(serviceBaseUri.toString() + "/" + VERSION_URI_PATH); HttpClient httpclient = new DefaultHttpClient(); try {//w w w . jav a 2 s. co m HttpGet httpget = new HttpGet(uri); LOGGER.debug("Retrieving service version from {}", httpget.getURI()); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpget, responseHandler); LOGGER.trace("Version response: {}", responseBody); Matcher matcher = VERSION_PATTERN.matcher(responseBody); if (matcher.matches()) { return matcher.group(1); } throw new IOException("Failed to retrieve version information"); } finally { httpclient.getConnectionManager().shutdown(); } }
From source file:biz.netcentric.cq.tools.actool.validators.Validators.java
public static boolean isValidAuthorizableId(final String name) { if (StringUtils.isBlank(name)) { return false; }//from w w w.j a va 2s .c o m boolean isValid = false; Matcher matcher = GROUP_ID_PATTERN.matcher(name); if (matcher.matches()) { isValid = true; } return isValid; }
From source file:com.netflix.genie.agent.AgentMetadataImpl.java
private static String getAgentPidOrFallback() { final String jvmId = ManagementFactory.getRuntimeMXBean().getName(); final Matcher pidPatternMatcher = Pattern.compile("(\\d+)@.*").matcher(jvmId); if (pidPatternMatcher.matches() && !StringUtils.isBlank(pidPatternMatcher.group(1))) { return pidPatternMatcher.group(1); }//from w w w .j av a2 s. c o m log.warn("Failed to retrieve agent PID (JVM id: {})", jvmId); return FALLBACK_STRING; }
From source file:eu.stratosphere.nephele.instance.InstanceTypeFactory.java
/** * Constructs an {@link InstanceType} object by parsing a hardware description string. * // w w w. java 2 s . c o m * @param description * the hardware description reflected by this instance type * @return an instance type reflecting the given hardware description or <code>null</code> if the description cannot * be parsed */ public static InstanceType constructFromDescription(String description) { final Matcher m = INSTANCE_TYPE_PATTERN.matcher(description); if (!m.matches()) { LOG.error("Cannot extract instance type from string " + description); return null; } final String identifier = m.group(1); final int numComputeUnits = Integer.parseInt(m.group(2)); final int numCores = Integer.parseInt(m.group(3)); final int memorySize = Integer.parseInt(m.group(4)); final int diskCapacity = Integer.parseInt(m.group(5)); final int pricePerHour = Integer.parseInt(m.group(6)); return new InstanceType(identifier, numComputeUnits, numCores, memorySize, diskCapacity, pricePerHour); }