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.moviejukebox.plugin.FilmaffinityPlugin.java
@Override public boolean scanNFO(String nfo, Movie movie) { Pattern filtroFAiD = Pattern.compile( "http://www.filmaffinity.com/es/film([0-9]{6})\\.html|filmaffinity=((?:film)?[0-9]{6}(?:\\.html)?)|<id moviedb=\"filmaffinity\">((?:film)?[0-9]{6}(?:\\.html)?)</id>", Pattern.CASE_INSENSITIVE); Matcher nfoMatcher = filtroFAiD.matcher(nfo); boolean result = false; if (nfoMatcher.find()) { if (nfoMatcher.group(1) != null) { movie.setId(FilmAffinityInfo.FILMAFFINITY_PLUGIN_ID, filmAffinityInfo.arrangeId(nfoMatcher.group(1))); } else if (nfoMatcher.group(2) != null) { movie.setId(FilmAffinityInfo.FILMAFFINITY_PLUGIN_ID, filmAffinityInfo.arrangeId(nfoMatcher.group(2))); } else {/*from ww w .j a v a 2 s . c o m*/ movie.setId(FilmAffinityInfo.FILMAFFINITY_PLUGIN_ID, filmAffinityInfo.arrangeId(nfoMatcher.group(3))); } result = true; } // Look for IMDb id super.scanNFO(nfo, movie); return result; }
From source file:com.github.sevntu.checkstyle.checks.coding.CustomDeclarationOrderCheck.java
/** * Set whether or not the match is case sensitive. * * @param aCaseSensitive true if the match is case sensitive. *//*from w w w .ja v a2s. c o m*/ public void setCaseSensitive(final boolean aCaseSensitive) { // 0 - case sensitive flag mCompileFlags = aCaseSensitive ? 0 : Pattern.CASE_INSENSITIVE; for (FormatMatcher currentRule : mCustomOrderDeclaration) { currentRule.setCompileFlags(mCompileFlags); } }
From source file:esg.node.filters.AccessLoggingFilter.java
public void init(FilterConfig filterConfig) throws ServletException { System.out.println("Initializing filter: " + this.getClass().getName()); this.filterConfig = filterConfig; ESGFProperties esgfProperties = null; try {/*from w ww . j a v a2 s. c o m*/ esgfProperties = new ESGFProperties(); } catch (java.io.IOException e) { e.printStackTrace(); log.error(e); } String value = null; dbProperties = new Properties(); log.debug("FilterConfig is : [" + filterConfig + "]"); log.debug("db.protocol is : [" + filterConfig.getInitParameter("db.protocol") + "]"); dbProperties.put("db.protocol", ((null != (value = filterConfig.getInitParameter("db.protocol"))) ? value : esgfProperties.getProperty("db.protocol"))); value = null; dbProperties.put("db.host", ((null != (value = filterConfig.getInitParameter("db.host"))) ? value : esgfProperties.getProperty("db.host"))); value = null; dbProperties.put("db.port", ((null != (value = filterConfig.getInitParameter("db.port"))) ? value : esgfProperties.getProperty("db.port"))); value = null; dbProperties.put("db.database", ((null != (value = filterConfig.getInitParameter("db.database"))) ? value : esgfProperties.getProperty("db.database"))); value = null; dbProperties.put("db.user", ((null != (value = filterConfig.getInitParameter("db.user"))) ? value : esgfProperties.getProperty("db.user"))); value = null; dbProperties.put("db.password", ((null != (value = filterConfig.getInitParameter("db.password"))) ? value : esgfProperties.getDatabasePassword())); value = null; dbProperties.put("db.driver", ((null != (value = filterConfig.getInitParameter("db.driver"))) ? value : esgfProperties.getProperty("db.driver", "org.postgresql.Driver"))); value = null; serviceName = (null != (value = filterConfig.getInitParameter("service.name"))) ? value : "thredds"; value = null; log.debug("Database parameters: " + dbProperties); DatabaseResource.init(dbProperties.getProperty("db.driver", "org.postgresql.Driver")) .setupDataSource(dbProperties); DatabaseResource.getInstance().showDriverStats(); accessLoggingDAO = new AccessLoggingDAO(DatabaseResource.getInstance().getDataSource()); //------------------------------------------------------------------------ // Extensions that this filter will handle... //------------------------------------------------------------------------ String extensionsParam = filterConfig.getInitParameter("extensions"); if (extensionsParam == null) { extensionsParam = ""; } //defensive program against null for this param String[] extensions = (".nc," + extensionsParam.toString()).split(","); StringBuffer sb = new StringBuffer(); for (int i = 0; i < extensions.length; i++) { sb.append(extensions[i].trim()); if (i < extensions.length - 1) sb.append("|"); } System.out.println("Applying filter for files with extensions: " + sb.toString()); String regex = "http.*(?:" + sb.toString() + ")$"; System.out.println("Regex = " + regex); urlExtensionPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); //------------------------------------------------------------------------ //------------------------------------------------------------------------ // Extensions that this filter will NOT handle... //------------------------------------------------------------------------ String exemptExtensionsParam = filterConfig.getInitParameter("exempt_extensions"); if (exemptExtensionsParam == null) { exemptExtensionsParam = ""; } //defensive program against null for this param String[] exemptExtensions = (".xml," + exemptExtensionsParam.toString()).split(","); sb = new StringBuffer(); for (int i = 0; i < exemptExtensions.length; i++) { sb.append(exemptExtensions[i].trim()); if (i < exemptExtensions.length - 1) sb.append("|"); } System.out.println("Exempt extensions: " + sb.toString()); regex = "http.*(?:" + sb.toString() + ")$"; System.out.println("Exempt Regex = " + regex); exemptUrlPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); //------------------------------------------------------------------------ //------------------------------------------------------------------------ // Patterns that this filter will NOT handle: Because the output is not file based... //------------------------------------------------------------------------ String exemptServiceParam = filterConfig.getInitParameter("exempt_services"); if (exemptServiceParam == null) { exemptServiceParam = "x"; } //defensive program against null for this param String[] exemptServiceParams = (exemptServiceParam.toString()).split(","); sb = new StringBuffer(); for (int i = 0; i < exemptServiceParams.length; i++) { sb.append(exemptServiceParams[i].trim()); if (i < exemptServiceParams.length - 1) sb.append("|"); } System.out.println("Exempt services: " + exemptServiceParam); String exemptServiceRegex = "http[s]?://([^:/]*)(:(?:[0-9]*))?/(?:" + sb.toString() + ")/(.*$)"; exemptServicePattern = Pattern.compile(exemptServiceRegex, Pattern.CASE_INSENSITIVE); System.out.println("Exempt Service Regex = " + exemptServiceRegex); //------------------------------------------------------------------------ log.trace(accessLoggingDAO.toString()); String svc_prefix = esgfProperties.getProperty("node.download.svc.prefix", "thredds/fileServer"); String mountedPathRegex = "http[s]?://([^:/]*)(:(?:[0-9]*))?/" + svc_prefix + "(.*$)"; mountedPathPattern = Pattern.compile(mountedPathRegex, Pattern.CASE_INSENSITIVE); String urlRegex = "http[s]?://([^:/]*)(:(?:[0-9]*))?/(.*$)"; urlPattern = Pattern.compile(urlRegex, Pattern.CASE_INSENSITIVE); mpResolver = new MountedPathResolver((new esg.common.util.ESGIni()).getMounts()); }
From source file:com.moviejukebox.scanner.MovieDirectoryScanner.java
/** * Checks the file or directory passed to determine if it should be excluded * from the scan// w ww . j a va 2s . c om * * @param srcPath * @param file * @return boolean flag, true if the file should be excluded, false * otherwise */ protected boolean isFiltered(MediaLibraryPath srcPath, File file) { boolean isDirectory = file.isDirectory(); String filename = file.getName(); // Skip these parts if the file is a directory if (!isDirectory) { int index = filename.lastIndexOf('.'); if (index < 0) { return true; } String extension = file.getName().substring(index + 1).toUpperCase(); if (!supportedExtensions.contains(extension)) { return true; } // Exclude files without external subtitles if (StringUtils.isBlank(opensubtitles)) { // We are not downloading subtitles, so exclude those that don't have any. if (excludeFilesWithoutExternalSubtitles && !hasSubtitles(file)) { LOG.info("File {} excluded. (no external subtitles)", filename); return true; } } } // Compute the relative filename String relativeFilename = file.getAbsolutePath().substring(mediaLibraryRootPathIndex); String relativeFileNameLower = relativeFilename.toLowerCase(); String jukeboxName = PropertiesUtil.getProperty("mjb.detailsDirName", "Jukebox"); for (String excluded : srcPath.getExcludes()) { if (excluded.length() > 0) { try { Pattern excludePatt = Pattern.compile(excluded, Pattern.CASE_INSENSITIVE); if (excludePatt.matcher(relativeFileNameLower).find()) { LOG.debug("{} '{}' excluded.", isDirectory ? "Directory" : "File", relativeFilename); return true; } } catch (Exception error) { LOG.info("Error processing exclusion pattern: {}, {}", excluded, error.getMessage()); } excluded = excluded.replace("/", File.separator); excluded = excluded.replace("\\", File.separator); if (relativeFileNameLower.contains(excluded.toLowerCase())) { // Don't print a message for the exclusion of Jukebox files if (!relativeFileNameLower.contains(jukeboxName)) { LOG.debug("{} '{}' excluded.", isDirectory ? "Directory" : "File", relativeFilename); } return true; } } } // Handle special case of RARs. If ".rar", and it is ".partXXX.rar" // exclude all NON-"part001.rar" files. Matcher m = PATTERN_RAR_PART.matcher(relativeFileNameLower); if (m.find() && (m.groupCount() == 1)) { if (Integer.parseInt(m.group(1)) != 1) { LOG.debug("Excluding file '{}' as it is a non-first part RAR archive ({})", relativeFilename, m.group(1)); return true; } } return false; }
From source file:com.manydesigns.portofino.pageactions.text.TextAction.java
protected String processLocalUrls(String content) { List<String> hosts = new ArrayList<String>(); hosts.add(context.getRequest().getLocalAddr()); hosts.add(context.getRequest().getLocalName()); hosts.addAll(portofinoConfiguration.getList(PortofinoProperties.HOSTNAMES)); String patternString = BASE_USER_URL_PATTERN.replace("HOSTS", "(" + StringUtils.join(hosts, ")|(") + ")"); Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(content); int lastEnd = 0; StringBuilder sb = new StringBuilder(); String contextPath = context.getRequest().getContextPath(); while (matcher.find()) { String attribute = matcher.group(1); String path = matcher.group(8 + hosts.size()); assert path.startsWith("/"); String queryString = matcher.group(10 + hosts.size()); String hostAndPort = matcher.group(5); if (!StringUtils.isBlank(hostAndPort) && !path.startsWith(contextPath)) { logger.debug("Path refers to another web application on the same host, skipping: {}", path); continue; }//www.j a v a 2 s. c om sb.append(content.substring(lastEnd, matcher.start())); sb.append("portofino:hrefAttribute=\"").append(attribute).append("\""); if (path.startsWith(contextPath)) { path = path.substring(contextPath.length()); } //path = convertPathToInternalLink(path); sb.append(" portofino:link=\"").append(path).append("\""); if (!StringUtils.isBlank(queryString)) { sb.append(" portofino:queryString=\"").append(queryString).append("\""); } lastEnd = matcher.end(); } sb.append(content.substring(lastEnd)); return sb.toString(); }
From source file:com.android.email.core.internet.MimeUtility.java
/** * Returns true if the given mimeType matches the matchAgainst specification. The comparison * ignores case and the matchAgainst string may include "*" for a wildcard (e.g. "image/*"). * //from w ww . ja v a 2 s. co m * @param mimeType A MIME type to check. * @param matchAgainst A MIME type to check against. May include wildcards. * @return true if the mimeType matches */ public static boolean mimeTypeMatches(String mimeType, String matchAgainst) { Pattern p = Pattern.compile(matchAgainst.replaceAll("\\*", "\\.\\*"), Pattern.CASE_INSENSITIVE); return p.matcher(mimeType).matches(); }
From source file:com.mmj.app.web.controller.user.UserController.java
@RequestMapping(value = "/profile/update") public ModelAndView profileUpdate(String jid, String nick, String imgUrl, String sex, String proveName, String cityName) {/*from w w w . j a v a 2s .c om*/ if (StringUtils.isEmpty(jid)) { return createJsonMav("0000", "?,??", ""); } if (StringUtils.isEmpty(nick)) { return createJsonMav("0000", "?,", ""); } MemberDO member = new MemberDO(nick); if (StringUtils.isNotEmpty(imgUrl)) { Pattern p = Pattern.compile(IMG_URL_REG, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(WEB_APP_HOST + imgUrl); logger.error("imgUrl: " + WEB_APP_HOST + imgUrl); logger.error("imgUrl matches: " + m.matches()); if (!m.matches()) { return createJsonMav("0000", "?,?", ""); } member.setPic(imgUrl); } if (StringUtils.isNotEmpty(sex)) { SexEnum sexEnum = SexEnum.getEnum(sex); if (sexEnum == null) { return createJsonMav("0000", "?,", ""); } member.setSex(sexEnum.getValue()); } MemberDO memberDO = userService.find(new MemberQuery("", nick, "")); if (memberDO != null) { if (!StringUtils.equals(jid, memberDO.getName())) { return createJsonMav("0000", "?,?", ""); } } if (StringUtils.isNotEmpty(proveName)) { member.setProvince(proveName); } if (StringUtils.isNotEmpty(cityName)) { member.setCity(cityName); } member.setId(WebUserTools.getUid()); userService.update(member); return createJsonMav("9999", "??", ""); }
From source file:de.mpg.escidoc.services.syndication.feed.Feed.java
/** * Generate <code>UriMatcher</code> for the feed and list of the parameters <code>paramList</code> * according to the <code>uri</code>. * @param uri//from w w w . j a va 2s . c o m */ public void generateUriMatcher(final String uri) { String result = new String(uri); result = escapeUri(result); //property regexp in uri String regexp = "(\\$\\{[\\w.]+?\\})"; Matcher m = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(uri); while (m.find()) { String param = m.group(1); paramList.add(param); result = result.replaceFirst(Utils.quoteReplacement(param), "\\(.+\\)?"); } setUriMatcher(result); }
From source file:eu.semlibproject.annotationserver.AdminDataHelper.java
public boolean areEmailsValid(String receivers) { String expression = "([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\\.)+[A-Z]{2,6},?)*"; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); if (receivers.contains(";")) { for (String receiver : receivers.split(";")) { CharSequence inputStr = StringUtils.trim(receiver); Matcher matcher = pattern.matcher(inputStr); if (!matcher.matches()) return false; }// w w w.j a v a 2 s . c o m return true; } else { CharSequence inputStr = StringUtils.trim(receivers); Matcher matcher = pattern.matcher(inputStr); return matcher.matches(); } }
From source file:fr.ortolang.diffusion.api.content.ContentResource.java
private Response export(boolean connected, String followSymlink, String filename, String format, List<String> paths, String regex, SecurityContext securityContext) throws UnsupportedEncodingException { if (connected && securityContext.getUserPrincipal() == null) { LOGGER.log(Level.FINE, "user is not authenticated, redirecting to authentication"); Map<String, Object> params = new HashMap<>(); params.put("followSymlink", followSymlink); params.put("filename", filename); params.put("format", format); params.put("path", paths); params.put("regex", regex); String id = UUID.randomUUID().toString(); exportations.put(id, params);//from ww w .java 2 s . c o m String redirect = "/content/exportations/" + id; String encodedRedirect = Base64.getUrlEncoder().encodeToString(redirect.getBytes()); NewCookie rcookie = new NewCookie(AuthResource.REDIRECT_PATH_PARAM_NAME, encodedRedirect, OrtolangConfig.getInstance().getProperty(OrtolangConfig.Property.API_CONTEXT), uriInfo.getBaseUri().getHost(), 1, "Redirect path after authentication", 300, new Date(System.currentTimeMillis() + 300000), false, false); UriBuilder builder = UriBuilder.fromResource(ContentResource.class); builder.queryParam("followsymlink", followSymlink).queryParam("filename", filename) .queryParam("format", format).queryParam("path", paths); return Response .seeOther(uriInfo.getBaseUriBuilder().path(AuthResource.class) .queryParam(AuthResource.REDIRECT_PATH_PARAM_NAME, encodedRedirect).build()) .cookie(rcookie).build(); } Pattern pattern = null; if (regex != null) { pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); } ResponseBuilder builder = handleExport(false, filename, format, paths, pattern); return builder.build(); }