List of usage examples for java.util.regex Pattern matches
public static boolean matches(String regex, CharSequence input)
From source file:JavaMvc.web.SignupValidator.java
public void validate(Object o, Errors errors) { SignupCommand command = (SignupCommand) o; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.username.empty", "Please specify a username."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "error.email.empty", "Please specify an email address."); if (StringUtils.hasText(command.getEmail()) && !Pattern.matches(SIMPLE_EMAIL_REGEX, command.getEmail().toUpperCase())) { errors.rejectValue("email", "error.email.invalid", "Please enter a valid email address."); }//from w w w . j a v a2 s. c o m ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "error.password.empty", "Please specify a password."); }
From source file:JavaMvc.web.EditUserValidator.java
public void validate(Object o, Errors errors) { EditUserCommand command = (EditUserCommand) o; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.username.empty", "Please specify a username."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "error.email.empty", "Please specify an email address."); if (StringUtils.hasText(command.getEmail()) && !Pattern.matches(SIMPLE_EMAIL_REGEX, command.getEmail().toUpperCase())) { errors.rejectValue("email", "error.email.invalid", "Please enter a valid email address."); }//from w w w . j av a 2 s . com }
From source file:csns.web.validator.CourseValidator.java
@Override public void validate(Object target, Errors errors) { Course course = (Course) target;/*from w w w . j a v a 2 s . com*/ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.field.required"); String code = course.getCode(); if (!StringUtils.hasText(code)) errors.rejectValue("code", "error.field.required"); else if (!Pattern.matches("[A-Z]+\\d+[A-Z]?", code)) errors.rejectValue("code", "error.course.code.invalid"); else { Course c = courseDao.getCourse(code); if (c != null && !c.getId().equals(course.getId())) errors.rejectValue("code", "error.course.exists"); } }
From source file:ch.cyberduck.core.StringAppender.java
public StringAppender append(final String message) { if (StringUtils.isBlank(message)) { return this; }//from w w w . j a v a 2 s .c om if (buffer.length() > 0) { buffer.append(" "); } buffer.append(StringUtils.trim(message)); if (buffer.charAt(buffer.length() - 1) == '.') { return this; } if (buffer.charAt(buffer.length() - 1) == ':') { buffer.deleteCharAt(buffer.length() - 1); } if (!Pattern.matches("[.?!]", String.valueOf(buffer.charAt(buffer.length() - 1)))) { buffer.append(suffix); } return this; }
From source file:org.xinta.eazycode.components.shiro.web.validator.EditUserValidator.java
public void validate(Object o, Errors errors) { EditUserVO command = (EditUserVO) o; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "loginName", "error.loginName.empty", "Please specify a loginName."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "error.email.empty", "Please specify an email address."); if (StringUtils.hasText(command.getEmail()) && !Pattern.matches(SIMPLE_EMAIL_REGEX, command.getEmail().toUpperCase())) { errors.rejectValue("email", "error.email.invalid", "Please enter a valid email address."); }/* ww w .j a v a2s . co m*/ }
From source file:com.adobe.acs.commons.version.impl.EvolutionConfig.java
public boolean handleResource(String name) { for (String entry : ignoreResources) { if (Pattern.matches(entry, name)) { return false; }//from w ww. j a v a 2 s . c o m } return true; }
From source file:cdr.forms.DepositFile.java
public String getExtension() { String extension = ""; int index = filename.lastIndexOf('.'); if (index > 0) extension = filename.substring(index); if (!Pattern.matches("^\\.[a-zA-Z0-9]+$", extension)) extension = ""; return extension; }
From source file:com.bstek.dorado.view.type.property.validator.RegExpValidator.java
protected boolean match(String regExp, String s) { return Pattern.matches(regExp, s); }
From source file:com.wyb.utils.util.PatternUtil.java
/** * ?????+86135xxxx...+00852137xxxx.../*www . j av a 2 s . c o m*/ * * @param mobile ??????? * <p>?134(0-8)?135?136?137?138?139?147TD? * ?150?151?152?157TD?158?159?187??188TD</p> * <p>??130?131?132?155?156?185??1863g</p> * <p>?133?153?180??189</p> * @return ??true?false */ public static boolean isMobile(String mobile) { if (StringUtils.isBlank(mobile)) { return false; } String regex = "(\\+\\d+)?1[34578]\\d{9}$"; return Pattern.matches(regex, mobile); }
From source file:com.github.zhanhb.ckfinder.connector.utils.PathUtils.java
/** * Adds slash character at the start of String provided as parameter. The * slash character will not be added if parameter is ULR or starts with slash. * * @param string string to add slash character to * @return String with slash character at the beginning, {@code null} or full * URL./* w w w.ja v a 2 s . c om*/ */ public static String addSlashToBegin(String string) { if (string == null || string.startsWith("/") || Pattern.matches(Constants.URL_REGEX, string)) { return string; } return "/".concat(string); }