List of usage examples for java.util.regex Pattern CASE_INSENSITIVE
int CASE_INSENSITIVE
To view the source code for java.util.regex Pattern CASE_INSENSITIVE.
Click Source Link
From source file:com.duroty.controller.actions.GoogieSpellAction.java
protected Vector getMatches(String text) { Pattern pattern = Pattern.compile( "<c o=\\\"([^\\\"]*)\\\" l=\\\"([^\\\"]*)\\\" s=\\\"([^\\\"]*)\\\">([^<]*)<\\/c>", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(text); Vector vector = new Vector(); while (matcher.find()) { int groupCount = matcher.groupCount(); vector.addElement(matcher.group(0)); for (int i = 0; i < groupCount; i++) { DLog.log(DLog.WARN, this.getClass(), "GROUP: " + i + " >> " + matcher.group(i)); }/*from ww w .ja va2s . com*/ } return vector; }
From source file:com.redhat.rhn.domain.channel.NewChannelHelper.java
/** * Verifies a potential GPG ID for a channel * @param gpgId the gpg id of the channel * @return true if it is correct, false otherwise *//*from w ww . j av a 2s .c o m*/ public static boolean verifyGpgId(String gpgId) { Pattern pattern = Pattern.compile("^[0-9A-F]{8}$", Pattern.CASE_INSENSITIVE); Matcher match = pattern.matcher(gpgId); return match.matches(); }
From source file:dk.dma.msinm.web.rest.LocationRestService.java
/** * Annoyingly, different versions of KML use different default namespaces. * Hence, attempt to extract the default namespace * @param kml the xml//from ww w.java2 s .c o m * @return the default KML namespace */ private String extractDefaultNamespace(String kml) { Pattern p = Pattern.compile(".*<kml xmlns=\"([^\"]*)\".*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE); Matcher m = p.matcher(kml); if (m.matches()) { return m.group(1); } return "http://www.opengis.net/kml/2.2"; }
From source file:fr.dudie.acrachilisync.utils.IssueDescriptionReader.java
/** * Extracts the list of bug occurrences from the description. * /*from w ww . ja v a 2 s . c o m*/ * @param pDescription * the issue description * @param pStacktraceMD5 * the stacktrace MD5 hash the issue is related to * @return the ACRA bug occurrences listed in the description * @throws IssueParseException * malformed issue description */ private List<ErrorOccurrence> parseAcraOccurrencesTable(final String pDescription, final String pStacktraceMD5) throws IssueParseException { final List<ErrorOccurrence> occur = new ArrayList<ErrorOccurrence>(); // escape braces { and } to use strings in regexp final String header = IssueDescriptionUtils.getOccurrencesTableHeader(); final String escHeader = Pattern.quote(header); // regexp to find occurrences tables final Pattern p = Pattern.compile(escHeader + IssueDescriptionUtils.EOL + "(?:" + OCCURR_LINE_PATTERN + IssueDescriptionUtils.EOL + "+)+", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); final Matcher m = p.matcher(pDescription); if (m.find()) { // regexp to find occurrences lines final Pattern pLine = Pattern.compile(OCCURR_LINE_PATTERN); final Matcher mLine = pLine.matcher(m.group()); while (mLine.find()) { try { final StringTokenizer line = new StringTokenizer(mLine.group(), "|"); final String acraReportId = line.nextToken(); final String acraUserCrashDate = line.nextToken(); final String acraRunFor = line.nextToken(); final String acraAndroidVersion = line.nextToken(); final String acraVersionCode = line.nextToken(); final String acraVersionName = line.nextToken(); final String acraDevice = line.nextToken(); final ErrorOccurrence error = new ErrorOccurrence(); error.setReportId(acraReportId); try { error.setCrashDate(IssueDescriptionUtils.parseDate(acraUserCrashDate)); error.setRunFor(RunningTimeUtils.parseRunningTime(acraRunFor)); } catch (final ParseException e) { throw new IssueParseException( "Unable to parse user crash date of ACRA report " + acraReportId, e); } error.setAndroidVersion(acraAndroidVersion); error.setVersionCode(acraVersionCode); error.setVersionName(acraVersionName); error.setDevice(acraDevice); occur.add(error); } catch (final NoSuchElementException e) { throw new IssueParseException("Unable to parse ACRA report line: " + mLine.group(), e); } } } else { throw new IssueParseException("No crash occurrence table found in the description"); } if (m.find()) { throw new IssueParseException("More than 1 occurrence table found in the description"); } if (CollectionUtils.isEmpty(occur)) { throw new IssueParseException("0 user crash occurrence found in the description"); } return occur; }
From source file:AIR.Common.Web.Session.CaseInsensitiveFileNameFilter.java
private void setupExtensionsPattern(FilterConfig filterConfig) { String extensions = filterConfig.getInitParameter("extensionsToFilter"); if (StringUtils.isEmpty(extensions)) { _logger.warn(/* w w w .j a v a2 s .c om*/ "No extensions provided to filter on. No filtering will be done. Please fill out the extensionsToFilter init-param for CaseInsensitiveFileNameFilter. Extensions are pipe (|) seperated."); } else { _pattern = Pattern.compile(String.format(".*\\.(?:%s)$", extensions), Pattern.CASE_INSENSITIVE); } }
From source file:com.qmetry.qaf.automation.util.StringUtil.java
public static boolean seleniumEquals(String expectedPattern, String actual) { if ((expectedPattern == null) || (actual == null)) { return expectedPattern == actual; }/* w w w.j ava 2s . c om*/ if (actual.startsWith("regexp:") || actual.startsWith("regex:") || actual.startsWith("regexpi:") || actual.startsWith("regexi:") || actual.startsWith("start:") || actual.startsWith("end:") || actual.startsWith("in:")) { // swap 'em String tmp = actual; actual = expectedPattern; expectedPattern = tmp; } if (expectedPattern.startsWith("start:")) { return actual.startsWith(expectedPattern.replaceFirst("start:", "")); } if (expectedPattern.startsWith("end:")) { return actual.endsWith(expectedPattern.replaceFirst("end:", "")); } if (expectedPattern.startsWith("in:")) { return actual.contains(expectedPattern.replaceFirst("in:", "")); } Boolean b; b = handleRegex("regexp:", expectedPattern, actual, 0); if (b != null) { return b.booleanValue(); } b = handleRegex("regex:", expectedPattern, actual, 0); if (b != null) { return b.booleanValue(); } b = handleRegex("regexpi:", expectedPattern, actual, Pattern.CASE_INSENSITIVE); if (b != null) { return b.booleanValue(); } b = handleRegex("regexi:", expectedPattern, actual, Pattern.CASE_INSENSITIVE); if (b != null) { return b.booleanValue(); } if (expectedPattern.startsWith("exact:")) { String expectedExact = expectedPattern.replaceFirst("exact:", ""); if (!expectedExact.equals(actual)) { System.out.println("expected " + actual + " to match " + expectedPattern); return false; } return true; } String expectedGlob = expectedPattern.replaceFirst("glob:", ""); expectedGlob = expectedGlob.replaceAll("([\\]\\[\\\\{\\}$\\(\\)\\|\\^\\+.])", "\\\\$1"); expectedGlob = expectedGlob.replaceAll("\\*", ".*"); expectedGlob = expectedGlob.replaceAll("\\?", "."); if (!Pattern.compile(expectedGlob, Pattern.DOTALL).matcher(actual).matches()) { System.out.println("expected \"" + actual + "\" to match glob \"" + expectedPattern + "\" (had transformed the glob into regexp \"" + expectedGlob + "\""); return false; } return true; }
From source file:cz.zcu.pia.social.network.frontend.components.login.ComponentRegister.java
/** * Tells if the form is valid// www .j a v a2s . co m * @return is valid */ protected boolean isValid() { if (!bean.getValidation().equals(TURRING_TEST)) { Notification.show(msgs.getMessage(ERROR_VALIDATION), Notification.Type.ERROR_MESSAGE); return false; } if (!bean.getPassword().equals(bean.getPasswordRepeat())) { Notification.show(msgs.getMessage(ERROR_PASSWORDS_DOESNT_MATCH), Notification.Type.ERROR_MESSAGE); password.setValue(""); passwordRepeat.setValue(""); return false; } if (usersService.getUserByUsername(bean.getUsername()) != null) { Notification.show(msgs.getMessage(ERROR_USERNAME_USED), Notification.Type.ERROR_MESSAGE); return false; } Pattern p = Pattern.compile("[^a-z0-9]", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(bean.getUsername()); boolean b = m.find(); if (b) { Notification.show(msgs.getMessage("username") + " " + msgs.getMessage("error.special-char") + "\n", msgs.getMessage("error.special-char.correct"), Notification.Type.ERROR_MESSAGE); return false; } return true; }
From source file:fr.dudie.acrachilisync.tools.upgrade.IssueDescriptionReaderV1.java
/** * Extracts the bug stacktrace from the description. * /*from w w w.j a v a2 s. c o m*/ * @param pDescription * the issue description * @param pStacktraceMD5 * the stacktrace MD5 hash the issue is related to * @return the stacktrace * @throws IssueParseException * malformed issue description */ private String parseStacktrace(final String pDescription, final String pStacktraceMD5) throws IssueParseException { String stacktrace = null; // escape braces { and } to use strings in regexp final String start = "<pre class=\"javastacktrace\">"; final String qStart = Pattern.quote(start); final String end = "</pre>"; final String qEnd = Pattern.quote(end); final Pattern p = Pattern.compile(qStart + "(.*)" + qEnd, Pattern.DOTALL | Pattern.CASE_INSENSITIVE); final Matcher m = p.matcher(pDescription); if (m.find()) { stacktrace = m.group(1); // if a start tag or an end tag is found in the stacktrace, then there is a problem if (StringUtils.contains(stacktrace, start) || StringUtils.contains(stacktrace, end)) { throw new IssueParseException("Invalid stacktrace block"); } } else { throw new IssueParseException("0 stacktrace block found in the description"); } return stacktrace; }
From source file:caarray.client.examples.java.CASRemoteEJBClient.java
private String getTicketValue(HttpResponse response) throws IOException { String result = ""; Header[] headers = response.getHeaders("Location"); String serviceTicketURL = headers[0].getValue(); Pattern p = Pattern.compile(".*ticket=(.*)$", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(serviceTicketURL); m.find();//from w ww .jav a 2 s . c om result = m.group(1); consumeEntity(response); return result; }
From source file:com.g3net.tool.StringUtils.java
/** * ???//from ww w . java 2 s . c om * * @param src * @param regexp * @param ignoreCase * @param startPos * ?? * @return */ public static boolean endsWith(String src, String regexp, boolean ignoreCase, TInteger startPos) { Pattern p = null; if (ignoreCase) { p = Pattern.compile(regexp + "$", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); } else { p = Pattern.compile(regexp + "$", Pattern.MULTILINE); } Matcher m = p.matcher(src); while (m.find()) { // log.info(m.group()+":"+m.start()+":"+m.end()); startPos.setValue(m.start()); return true; } return false; }