List of usage examples for com.google.gwt.regexp.shared RegExp compile
public static RegExp compile(String pattern)
From source file:cc.kune.chat.client.KuneChatNotifier.java
License:GNU Affero Public License
/** * Instantiates a new kune chat notifier. * * @param i18n//from ww w . j a va 2 s .c o m * the i18n * @param downUtils * the down utils * @param eventBus * the event bus */ public KuneChatNotifier(final I18nTranslationService i18n, final ClientFileDownloadUtils downUtils, final EventBus eventBus) { this.i18n = i18n; this.downUtils = downUtils; this.eventBus = eventBus; regExp = RegExp.compile("(.*) says (.*)"); }
From source file:cc.kune.common.client.utils.ClientFormattedString.java
License:GNU Affero Public License
/** * String format based in/*from ww w .ja v a2s .c o m*/ * http://stackoverflow.com/questions/3126232/string-formatter-in-gwt * * @param format * the format * @param args * the args * @return the string */ @Override public String format(final String format, final Object... args) { final RegExp regex = RegExp.compile("%[a-z]"); final SplitResult split = regex.split(format); final StringBuffer msg = new StringBuffer(); for (int pos = 0; pos < split.length() - 1; pos += 1) { msg.append(split.get(pos)); msg.append(args[pos].toString()); } msg.append(split.get(split.length() - 1)); GWT.log("FORMATTER: " + msg.toString()); return msg.toString(); }
From source file:ch.unifr.pai.twice.mousecontrol.client.TouchPadWidget.java
License:Apache License
/** * Helper method to extract values from the HTTP-response by the given regular expression * //from w ww.ja v a 2 s.c o m * @param response * @param regex * @return */ private static String extractByRegex(Response response, String regex) { RegExp re = RegExp.compile(regex); MatchResult result = re.exec(response.getText()); return result.getGroup(0); }
From source file:cimav.client.view.provider.DeptosProvider.java
@Override public boolean matchFilter(Departamento value, String filter) { if (value == null) { return false; }/*w ww. j a va 2s. co m*/ if (filter == null || filter.trim().isEmpty()) { return true; } // ^.*\b(one|two|three)\b.*$ one, tow or three // ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$ one, two AND three // ^(?=.*?one)(?=.*?two)(?=.*?three).*$ las palabras no tiene boundiry // la frase completa debe tener todos los terminos String pattern = "^"; filter = filter.toLowerCase(); String[] array = filter.split("\\s+"); for (String term : array) { pattern = pattern + "(?=.*?" + term.trim() + ")"; } pattern = pattern + ".+"; String string = value.getName() + " " + value.getCode(); string = string.toLowerCase(); RegExp regExp = RegExp.compile(pattern); MatchResult matcher = regExp.exec(string); return matcher != null; }
From source file:cimav.client.view.provider.EmpleadosBaseProvider.java
@Override public boolean matchFilter(EmpleadoBase value, String filter) { if (value == null) { return false; }/*from w w w .ja v a2s . c o m*/ if (filter == null || filter.trim().isEmpty()) { return true; } boolean hasAya = filter.toLowerCase().contains("a:"); if (hasAya) { filter = filter.replace("a:", ""); } boolean hasHon = filter.toLowerCase().contains("h:"); if (hasHon) { filter = filter.replace("h:", ""); } // ^.*\b(one|two|three)\b.*$ one, tow or three // ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$ one, two AND three // ^(?=.*?one)(?=.*?two)(?=.*?three).*$ las palabras no tiene boundiry // la frase completa debe tener todos los terminos String pattern = "^"; filter = filter.toLowerCase(); String[] array = filter.split("\\s+"); for (String term : array) { pattern = pattern + "(?=.*?" + term.trim() + ")"; } pattern = pattern + ".+"; String grupoStr = value.getGrupo() != null ? value.getGrupo().getCode() + " " + value.getGrupo().getName() : " "; String codeGrupolStr = value.getGrupo() != null ? value.getGrupo().getCode() : " "; String nivelStr = value.getNivel() != null ? value.getNivel().getCode() + " " + value.getNivel().getName() : " "; String sedeStr = value.getSede() != null ? value.getSede().getAbrev() + " " + value.getSede().getNombre() : " "; String deptoStr = value.getDepartamento() != null ? value.getDepartamento().getCode() + " " + value.getDepartamento().getName() : " "; String string = value.getName() /*+ " " + value.getRfc()*/ + " " + value.getCode() + " " + value.getCuentaCimav() + " " + grupoStr + " " + nivelStr + " " + sedeStr + " " + deptoStr; string = string.toLowerCase(); RegExp regExp = RegExp.compile(pattern); MatchResult matcher = regExp.exec(string); boolean result = matcher != null; if (hasAya) { result = result && (codeGrupolStr.toLowerCase().contains("aya")); } if (hasHon) { result = result && (codeGrupolStr.toLowerCase().contains("hon")); } return result; }
From source file:cimav.client.view.provider.EmpleadosProvider.java
@Override public boolean matchFilter(Empleado value, String filter) { if (value == null) { return false; }/* w ww .j a va 2 s .com*/ if (filter == null || filter.trim().isEmpty()) { return true; } // ^.*\b(one|two|three)\b.*$ one, tow or three // ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$ one, two AND three // ^(?=.*?one)(?=.*?two)(?=.*?three).*$ las palabras no tiene boundiry // la frase completa debe tener todos los terminos String pattern = "^"; filter = filter.toLowerCase(); String[] array = filter.split("\\s+"); for (String term : array) { pattern = pattern + "(?=.*?" + term.trim() + ")"; } pattern = pattern + ".+"; String grupoStr = value.getGrupo() != null ? value.getGrupo().getCode() + " " + value.getGrupo().getName() : " "; String nivelStr = value.getNivel() != null ? value.getNivel().getCode() + " " + value.getNivel().getName() : " "; String sedeStr = value.getSede() != null ? value.getSede().getAbrev() + " " + value.getSede().getNombre() : " "; String deptoStr = value.getDepartamento() != null ? value.getDepartamento().getCode() + " " + value.getDepartamento().getName() : " "; String string = value.getName() + " " + value.getRfc() + " " + value.getCode() + " " + value.getCuentaCimav() + " " + grupoStr + " " + nivelStr + " " + sedeStr + " " + deptoStr; string = string.toLowerCase(); RegExp regExp = RegExp.compile(pattern); MatchResult matcher = regExp.exec(string); return matcher != null; }
From source file:cmg.org.monitor.module.client.InviteUser.java
License:Open Source License
/** * Validate email.// w w w .j av a 2 s . com * * @param email the email * @return the string */ private static String validateEmail(String email) { String msg = ""; if (email == null || email == "") { msg = "This field is required"; } String pattern = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; RegExp regExp = RegExp.compile(pattern); String[] data = email.split(","); for (String em : data) { boolean matchFound = regExp.test(em); if (matchFound == false) { msg = "Email " + em + " is not validate"; return msg; } if (listUser3rds != null) { for (InvitedUser e : listUser3rds) { if (e.getEmail().toString().equals(em)) { msg = "Email : " + em + "is existed"; return msg; } } } } return msg; }
From source file:com.agnie.common.util.client.validator.ConstraintRegularExpressions.java
License:Open Source License
public static boolean validateWhiteSpace(String str) { RegExp pattern = RegExp.compile(ConstraintRegularExpressions.NO_WHITE_SPACE_EXP); MatchResult mr = pattern.exec(str); if ((mr != null) && (mr.toString().equals(mr.getInput()))) { return true; } else {// w ww . j a v a 2 s . c o m return false; } }
From source file:com.agnie.common.util.client.validator.ConstraintRegularExpressions.java
License:Open Source License
public static boolean validateEmail(String str) { RegExp patternUrl = RegExp.compile(ConstraintRegularExpressions.EMAIL_VALIDATOR_EXP); MatchResult mrUrl = patternUrl.exec(str); if ((mrUrl != null)) { return true; } else {/*from w ww . j a v a2 s . c o m*/ return false; } }
From source file:com.agnie.common.util.client.validator.ConstraintRegularExpressions.java
License:Open Source License
public static boolean validateUrl(String str) { RegExp patternUrl = RegExp.compile(ConstraintRegularExpressions.VALID_URL_EXP); MatchResult mrUrl = patternUrl.exec(str); if ((mrUrl != null)) { return true; } else {// ww w.j a v a 2s. c o m return false; } }