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.kegare.caveworld.util.CaveUtils.java
public static boolean containsIgnoreCase(String s1, String s2) { if (Strings.isNullOrEmpty(s1) || Strings.isNullOrEmpty(s2)) { return false; }/*from w w w . j av a2 s . c om*/ return Pattern.compile(Pattern.quote(s2), Pattern.CASE_INSENSITIVE).matcher(s1).find(); }
From source file:org.ocsinventoryng.android.actions.OCSProtocol.java
private String extractFreq(String message) { String resp = ""; Pattern p = Pattern.compile(".*<PROLOG_FREQ>(.*)</PROLOG_FREQ>.*", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(message); if (m.find()) { return m.group(1); }/*from w w w . j av a 2s . com*/ return resp; }
From source file:de.thm.arsnova.services.UserService.java
private void parseMailAddressPattern() { /* TODO: Add Unicode support */ List<String> domainList = Arrays.asList(allowedEmailDomains.split(",")); if (domainList.size() > 0) { List<String> patterns = new ArrayList<String>(); if (domainList.contains("*")) { patterns.add("([a-z0-9-]+\\.)+[a-z0-9-]+"); } else {/*from w ww. j a v a 2 s .c o m*/ Pattern patternPattern = Pattern.compile("[a-z0-9.*-]+", Pattern.CASE_INSENSITIVE); for (String patternStr : domainList) { if (patternPattern.matcher(patternStr).matches()) { patterns.add(patternStr.replaceAll("[.]", "[.]").replaceAll("[*]", "[a-z0-9-]+?")); } } } mailPattern = Pattern.compile("[a-z0-9._-]+?@(" + StringUtils.join(patterns, "|") + ")", Pattern.CASE_INSENSITIVE); LOGGER.info("Allowed e-mail addresses (pattern) for registration: " + mailPattern.pattern()); } }
From source file:com.symbian.driver.plugins.ftptelnet.FtpTransfer.java
private boolean delete(String aDirectory, String name) { boolean lReturn = true; String lName = name.replaceAll("\\*", "\\.\\*"); Pattern lPattern = Pattern.compile(lName, Pattern.CASE_INSENSITIVE); try {/*from ww w .ja v a2s . c om*/ lReturn = iFTP.changeWorkingDirectory(aDirectory); if (lReturn) { FTPFile[] lFiles = iFTP.listFiles(); for (int i = 0; i < lFiles.length; i++) { if (lFiles[i].isFile()) { if (lPattern.matcher(lFiles[i].getName()).matches()) { // delete the file LOGGER.info("Deleting file " + lFiles[i].getName()); lReturn = iFTP.deleteFile(lFiles[i].getName()); LOGGER.info("Delete file " + lFiles[i].getName()); } } } } else { lReturn = true; } } catch (IOException lIOException) { lReturn = false; LOGGER.log(Level.SEVERE, "FTP command failed : delete " + name, lIOException); } return lReturn; }
From source file:com.moviejukebox.plugin.ImdbPlugin.java
/** * Scan IMDB HTML page for the specified movie *///from w ww . jav a 2s.c o m private boolean updateImdbMediaInfo(Movie movie) { String imdbID = movie.getId(IMDB_PLUGIN_ID); if (!imdbID.startsWith("tt")) { imdbID = "tt" + imdbID; // Correct the ID if it's wrong movie.setId(IMDB_PLUGIN_ID, imdbID); } String xml = ImdbPlugin.this.getImdbUrl(movie); // Add the combined tag to the end of the request if required if (fullInfo) { xml += "combined"; } xml = getImdbData(xml); if (!Movie.TYPE_TVSHOW.equals(movie.getMovieType()) && (xml.contains("\"tv-extra\"") || xml.contains("\"tv-series-series\""))) { movie.setMovieType(Movie.TYPE_TVSHOW); return Boolean.FALSE; } // We can work out if this is the new site by looking for " - IMDb" at the end of the title String title = HTMLTools.extractTag(xml, "<title>"); if (!Movie.TYPE_TVSHOW.equals(movie.getMovieType()) && title.contains("(TV Series")) { movie.setMovieType(Movie.TYPE_TVSHOW); return Boolean.FALSE; } // Correct the title if "imdb" found if (StringUtils.endsWithIgnoreCase(title, " - imdb")) { title = title.substring(0, title.length() - 7); } else if (StringUtils.startsWithIgnoreCase(title, "imdb - ")) { title = title.substring(7); } // Remove the (VG) or (V) tags from the title title = title.replaceAll(" \\([VG|V]\\)$", ""); //String yearPattern = "(?i).\\((?:TV.|VIDEO.)?(\\d{4})(?:/[^\\)]+)?\\)"; String yearPattern = "(?i).\\((?:TV.|VIDEO.)?(\\d{4})"; Pattern pattern = Pattern.compile(yearPattern, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(title); if (matcher.find()) { // If we've found a year, set it in the movie if (OverrideTools.checkOverwriteYear(movie, IMDB_PLUGIN_ID)) { movie.setYear(matcher.group(1), IMDB_PLUGIN_ID); } // Remove the year from the title title = title.substring(0, title.indexOf(matcher.group(0))); } if (OverrideTools.checkOverwriteTitle(movie, IMDB_PLUGIN_ID)) { movie.setTitle(title, IMDB_PLUGIN_ID); } if (OverrideTools.checkOverwriteOriginalTitle(movie, IMDB_PLUGIN_ID)) { String originalTitle = title; if (xml.contains("<span class=\"title-extra\">")) { originalTitle = HTMLTools.extractTag(xml, "<span class=\"title-extra\">", "</span>"); if (originalTitle.contains("(original title)")) { originalTitle = originalTitle.replace(" <i>(original title)</i>", ""); } else { originalTitle = title; } } movie.setOriginalTitle(originalTitle, IMDB_PLUGIN_ID); } // Update the movie information updateInfo(movie, xml); // update common values updateInfoCommon(movie, xml); if (scrapeAwards) { updateAwards(movie); // Issue 1901: Awards } if (scrapeBusiness) { updateBusiness(movie); // Issue 2012: Financial information about movie } if (scrapeTrivia) { updateTrivia(movie); // Issue 2013: Add trivia } // TODO: Move this check out of here, it doesn't belong. if (downloadFanart && isNotValidString(movie.getFanartURL())) { movie.setFanartURL(getFanartURL(movie)); if (isValidString(movie.getFanartURL())) { movie.setFanartFilename(movie.getBaseName() + fanartToken + "." + fanartExtension); } } // always true return Boolean.TRUE; }
From source file:de.mpg.escidoc.services.reporting.ReportFHI.java
public static String replaceAllTotal(String what, String expr, String replacement) { return Pattern.compile(expr, Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(what) .replaceAll(replacement);//from w ww. ja v a 2s . co m }
From source file:com.thinkbiganalytics.nifi.rest.support.NifiProcessUtil.java
/** * Filters the specified list of process groups for ones matching the specified feed name, including versioned process groups. * * @param processGroups the list of process groups to filter * @param feedName the feed system name to match, case-insensitive * @return the matching process groups/*from www . j a v a2s . c o m*/ */ @Nonnull public static Set<ProcessGroupDTO> findProcessGroupsByFeedName( @Nonnull final Collection<ProcessGroupDTO> processGroups, @Nonnull final String feedName) { Pattern pattern = Pattern.compile("^" + Pattern.quote(feedName) + "( - \\d+)?$", Pattern.CASE_INSENSITIVE); return processGroups.stream().filter(processGroup -> pattern.matcher(processGroup.getName()).matches()) .collect(Collectors.toSet()); }
From source file:org.openhab.habdroid.ui.OpenHABWidgetArrayAdapter.java
@Override public String getNewValueAsFullText(String currentFullTextValue, float value) { String textValue = getRegExMatch(currentFullTextValue, Pattern.compile("\\d*\\[.,]?\\d*", Pattern.CASE_INSENSITIVE)); return currentFullTextValue.replaceFirst("\\d*\\[.,]?\\d*", Float.toString(value)); }
From source file:it.jnrpe.plugin.CheckHttp.java
/** * Apply logic to the http response and build metrics. * /*from w w w . j a v a 2 s . c o m*/ * @param opt * - * @param response * - * @param elapsed * - * @return - The metrics * @throws MetricGatheringException * List<Metric> */ private List<Metric> analyzeResponse(final ICommandLine opt, final String response, final int elapsed) throws MetricGatheringException { List<Metric> metrics = new ArrayList<Metric>(); metrics.add(new Metric("time", "", new BigDecimal(elapsed), null, null)); if (!opt.hasOption("certificate")) { if (opt.hasOption("string")) { boolean found = false; String string = opt.getOptionValue("string"); found = response.contains(string); metrics.add(new Metric("string", "", new BigDecimal(Utils.getIntValue(found)), null, null)); } if (opt.hasOption("expect")) { int count = 0; String[] values = opt.getOptionValue("expect").split(","); for (String value : values) { if (response.contains(value)) { count++; } } metrics.add(new Metric("expect", String.valueOf(count) + " times. ", new BigDecimal(count), null, null)); } if (opt.hasOption("regex")) { String regex = opt.getOptionValue("regex"); Pattern p = null; int flags = 0; if (opt.hasOption("eregi")) { flags = Pattern.CASE_INSENSITIVE; } if (opt.hasOption("linespan")) { flags = flags | Pattern.MULTILINE; } p = Pattern.compile(regex, flags); boolean found = p.matcher(response).find(); if (opt.hasOption("invert-regex")) { metrics.add(new Metric("invert-regex", String.valueOf(found), new BigDecimal(Utils.getIntValue(found)), null, null)); } else { metrics.add(new Metric("regex", String.valueOf(found), new BigDecimal(Utils.getIntValue(found)), null, null)); } } } return metrics; }
From source file:com.email.ReceiveEmail.java
/** * Strip out the emojis and symbols from the email so we can actually save * it in the database/*from w ww.java 2 s .co m*/ * * @param content String * @return String */ private static String removeEmojiAndSymbolFromString(String content) { String utf8tweet = ""; if (content != null) { try { byte[] utf8Bytes = content.getBytes("UTF-8"); utf8tweet = new String(utf8Bytes, "UTF-8"); } catch (UnsupportedEncodingException ex) { ExceptionHandler.Handle(ex); } Pattern unicodeOutliers = Pattern.compile( "[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]", Pattern.UNICODE_CASE | Pattern.CANON_EQ | Pattern.CASE_INSENSITIVE); Matcher unicodeOutlierMatcher = unicodeOutliers.matcher(utf8tweet); utf8tweet = unicodeOutlierMatcher.replaceAll(" "); } return utf8tweet; }