List of usage examples for java.util.regex Pattern matches
public static boolean matches(String regex, CharSequence input)
From source file:iddb.core.util.Validator.java
public static boolean isValidGuid(String value) { return Pattern.matches(RE_GUID, value); }
From source file:com.wyb.utils.util.PatternUtil.java
/** * ????/*from ww w . j a v a 2s . c o m*/ * * @param idCard ???15?18????? * @return ??true?false */ public static boolean isIdCard(String idCard) { if (StringUtils.isBlank(idCard)) { return false; } String regex = "[1-9]\\d{13,16}[a-zA-Z0-9]{1}"; return Pattern.matches(regex, idCard); }
From source file:com.baidu.rigel.biplatform.ac.util.PlaceHolderUtils.java
/** * ???KEY?? ${abc}/*from w ww . j a v a 2 s.c om*/ * <p> * ?????^\\$\\{[^\\}]+\\}$ * </p> * * @param placeHolder ?? * @return ????KEY */ public static String getKeyFromPlaceHolder(String placeHolder) { if (StringUtils.isBlank(placeHolder)) { throw new IllegalArgumentException("can not get key from empty placeHolder"); } if (!Pattern.matches("^\\$\\{[^\\}]+\\}$", placeHolder)) { return placeHolder; } else { return placeHolder.substring(2, placeHolder.length() - 1); } }
From source file:com.netflix.spinnaker.halyard.config.validate.v1.providers.AccountValidator.java
@Override public void validate(ConfigProblemSetBuilder p, Account n) { if (n.getName() == null) { p.addProblem(Severity.FATAL, "Account name must be specified"); } else if (!Pattern.matches(namePattern, n.getName())) { p.addProblem(Severity.ERROR, "Account name must match pattern " + namePattern).setRemediation( "It must start and end with a lower-case character or number, and only container lower-case character, numbers, dashes, or underscores"); }// w w w. j a va 2 s. c o m }
From source file:com.razorfish.forms.validation.MobileNumberValidator.java
@Override public void validate(final Object object, final Errors errors) { final UpdateMobileNumberForm updateMobileNumberForm = (UpdateMobileNumberForm) object; final String mobileNumber = updateMobileNumberForm.getMobileNumber(); final String password = updateMobileNumberForm.getPassword(); if (!StringUtils.isEmpty(mobileNumber) && !Pattern.matches(MOBILE_REGEX, mobileNumber)) { errors.rejectValue("mobileNumber", "profile.mobileNumber.invalid"); }/*from w w w . j a va2s . c om*/ if (StringUtils.isEmpty(password)) { errors.rejectValue("password", "profile.pwd.invalid"); } }
From source file:org.training.storefront.forms.validation.GuestValidator.java
@Override public void validate(final Object object, final Errors errors) { final GuestForm guestForm = (GuestForm) object; final String email = guestForm.getEmail(); if (StringUtils.isEmpty(email)) { errors.rejectValue("email", "profile.email.invalid"); } else if (StringUtils.length(email) > 255 || !Pattern.matches(EMAIL_REGEX, email)) { errors.rejectValue("email", "profile.email.invalid"); }//from w w w.j a va 2s. c o m }
From source file:org.akaza.openclinica.core.form.StringUtil.java
public static boolean isEmail(String s) { return Pattern.matches("[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*@[A-Za-z]+(\\.[A-Za-z]+)*", s) ? true : false; }
From source file:de.blizzy.documentr.validation.PagePathValidator.java
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; }/*ww w .ja va2s.co m*/ return Pattern.matches("^" + DocumentrConstants.PAGE_PATH_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:de.blizzy.documentr.validation.RoleNameValidator.java
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; }/*from www . ja v a 2 s. c o m*/ return Pattern.matches("^" + DocumentrConstants.ROLE_NAME_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:de.blizzy.documentr.validation.LoginNameValidator.java
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; }/*from ww w. j a v a2 s.co m*/ return Pattern.matches("^" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$ }