List of usage examples for java.util.regex Pattern DOTALL
int DOTALL
To view the source code for java.util.regex Pattern DOTALL.
Click Source Link
From source file:org.yes.cart.bulkexport.csv.impl.CsvExportColumnImpl.java
private Pattern getPattern() { if (pattern == null && StringUtils.isNotBlank(valueRegEx)) { pattern = Pattern.compile(valueRegEx, Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE | Pattern.DOTALL); }/*from w ww .j a v a 2 s .c o m*/ return pattern; }
From source file:org.wso2.carbon.la.core.utils.LogPatternExtractor.java
public static Map<String, String> processRegEx(String logLine, Map<String, String> regExs) { String value = null;//from w w w . j a v a2 s . com Map<String, String> logEvent = new HashMap<>(); for (Map.Entry<String, String> regEx : regExs.entrySet()) { Pattern p = Pattern.compile(".*?" + regEx.getValue(), Pattern.CASE_INSENSITIVE | Pattern.DOTALL); // apply "/" "/" ??? Matcher m = p.matcher(logLine); if (m.find()) { value = m.group(1).toString(); // add all the matching values } if (value != null) { logEvent.put(regEx.getKey(), value); } } return logEvent; }
From source file:info.magnolia.cms.util.SimpleUrlPattern.java
/** * Compile a regexp pattern handling <code>*</code> and <code>?</code> chars. * @param string input string//from www . ja v a2 s.c o m * @return a RegExp pattern */ public SimpleUrlPattern(String string) { this.length = StringUtils.removeEnd(string, "*").length(); this.pattern = Pattern.compile(getEncodedString(string), Pattern.DOTALL); this.patternString = string; }
From source file:org.opencastproject.adminui.userdirectory.UIRolesRoleProvider.java
private static boolean like(String string, final String query) { String regex = query.replace("_", ".").replace("%", ".*?"); Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL); return p.matcher(string).matches(); }
From source file:com.norconex.importer.handler.tagger.impl.TextBetweenTagger.java
@Override protected void tagStringContent(String reference, StringBuilder content, ImporterMetadata metadata, boolean parsed, boolean partialContent) { int flags = Pattern.DOTALL | Pattern.UNICODE_CASE; if (!caseSensitive) { flags = flags | Pattern.CASE_INSENSITIVE; }//from w ww . java 2 s. c o m for (TextBetween between : betweens) { List<Pair<Integer, Integer>> matches = new ArrayList<Pair<Integer, Integer>>(); Pattern leftPattern = Pattern.compile(between.start, flags); Matcher leftMatch = leftPattern.matcher(content); while (leftMatch.find()) { Pattern rightPattern = Pattern.compile(between.end, flags); Matcher rightMatch = rightPattern.matcher(content); if (rightMatch.find(leftMatch.end())) { if (inclusive) { matches.add(new ImmutablePair<Integer, Integer>(leftMatch.start(), rightMatch.end())); } else { matches.add(new ImmutablePair<Integer, Integer>(leftMatch.end(), rightMatch.start())); } } else { break; } } for (int i = matches.size() - 1; i >= 0; i--) { Pair<Integer, Integer> matchPair = matches.get(i); String value = content.substring(matchPair.getLeft(), matchPair.getRight()); if (value != null) { metadata.addString(between.name, value); } } } }
From source file:org.apache.tajo.storage.regex.RegexLineDeserializer.java
@Override public void init() { fieldSerDer = new TextFieldSerializerDeserializer(meta); fieldSerDer.init(schema);/* ww w . j a v a 2s .c o m*/ // Read the configuration parameters inputRegex = meta.getProperty(StorageConstants.TEXT_REGEX); boolean inputRegexIgnoreCase = "true" .equalsIgnoreCase(meta.getProperty(StorageConstants.TEXT_REGEX_CASE_INSENSITIVE, "false")); // Parse the configuration parameters if (inputRegex != null) { inputPattern = Pattern.compile(inputRegex, Pattern.DOTALL + (inputRegexIgnoreCase ? Pattern.CASE_INSENSITIVE : 0)); } else { throw new TajoRuntimeException(new InvalidTablePropertyException(StorageConstants.TEXT_REGEX, "This table does not have serde property \"" + StorageConstants.TEXT_REGEX + "\"!")); } if (nullChars != null) { nullChars.release(); } nullChars = TextLineSerDe.getNullChars(meta); }
From source file:com.android.dialer.lookup.yellowpages.YellowPagesApi.java
private String[] parseNameWebsiteCanada() { Pattern regexNameAndWebsite = Pattern.compile("class=\"ypgListingTitleLink utagLink\".*?href=\"(.*?)\">" + "(<span\\s+class=\"listingTitle\">.*?</span>)", Pattern.DOTALL); String name = null;//from w ww. jav a 2 s. c o m String website = null; Matcher m = regexNameAndWebsite.matcher(mOutput); if (m.find()) { website = m.group(1).trim(); name = LookupUtils.fromHtml(m.group(2).trim()); } if (website != null) { website = "http://www.yellowpages.ca" + website; } return new String[] { name, website }; }
From source file:org.apache.flume.sink.hbase.RegexHbaseEventSerializer.java
@Override public void configure(Context context) { String regex = context.getString(REGEX_CONFIG, REGEX_DEFAULT); regexIgnoreCase = context.getBoolean(IGNORE_CASE_CONFIG, INGORE_CASE_DEFAULT); inputPattern = Pattern.compile(regex, Pattern.DOTALL + (regexIgnoreCase ? Pattern.CASE_INSENSITIVE : 0)); String colNameStr = context.getString(COL_NAME_CONFIG, COLUMN_NAME_DEFAULT); String[] columnNames = colNameStr.split(","); for (String s : columnNames) { colNames.add(s.getBytes(Charsets.UTF_8)); }//from w w w.ja v a 2s. c o m }
From source file:lv.vizzual.numuri.service.operators.LVDataProvider.java
private String extractNetworkProvider(String page) { String provider = null;//from w w w . j ava2s . com if (page.contains("Mintes laik? var veikt tikai 5 pieprasjumus!")) { throw new RequestLimitReachedException(); } String exp = "Pakalpojuma nodroin?t?js </td><td><b>(.*?)</b>"; Pattern pattern = Pattern.compile(exp, Pattern.DOTALL | Pattern.UNIX_LINES); Matcher matcher = pattern.matcher(page); if (matcher.find()) { String providerHTML = matcher.group(1); provider = Html.fromHtml(providerHTML).toString(); } return cleanNetworkProvider(provider); }
From source file:au.org.ala.delta.ui.codeeditor.document.DirectiveTextDocument.java
public DirectiveTextDocument() { addTokenPattern(Token.COMMENT2, null, true, "\\*COMMENT\\s.*$"); DirectiveParser<C> parser = getDirectiveParser(); parser.visitDirectives(new DirectiveVisitor<C>() { @Override//w w w . j a v a2 s.com public void visit(AbstractDirective<C> directive) { String[] words = directive.getControlWords(); if (!words[0].equalsIgnoreCase("comment")) { StringBuilder sb = new StringBuilder("[*]"); for (int i = 0; i < words.length; ++i) { if (i > 0) { sb.append("\\s"); } if (words[i].length() > 3) { sb.append(words[i].substring(0, 3)); sb.append("\\w*"); } else { sb.append(words[i]); } } List<String> wordList = new ArrayList<String>(); int i = 0; while (i < words.length && wordList.size() < 3) { wordList.add(words[i]); i++; } String pattern = String.format("<h5><a name=\"_[*]%s_*\"></a>(.*?)</h5>(.*?)<h5>", StringUtils.join(wordList, "_").toUpperCase()); Pattern regex = Pattern.compile(pattern, Pattern.DOTALL); Matcher m = regex.matcher(_helpFile); String desc = directive.getClass().getCanonicalName(); if (m.find()) { desc = m.group(2); } DirectiveTooltipContent tooltip = new DirectiveTooltipContent( StringUtils.join(words, " ").toUpperCase(), desc, 0); addTokenPattern(Token.KEYWORD1, tooltip, true, sb.toString()); } } }); }