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:com.norconex.collector.core.filter.impl.RegexMetadataFilter.java
public final void setRegex(String regex) { this.regex = regex; if (regex != null) { int flags = Pattern.DOTALL; if (!caseSensitive) { flags = flags | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE; }// w w w . j a v a 2 s .c o m this.pattern = Pattern.compile(regex, flags); } else { this.pattern = Pattern.compile(".*"); } }
From source file:com.google.code.configprocessor.processing.ModifyAction.java
protected int parseFlags() { int flagsToUse = 0; String flagsToTest = getFlags() == null ? DEFAULT_PATTERN_FLAGS : getFlags(); String[] flagArray = StringUtils.split(flagsToTest, PATTERN_FLAG_SEPARATOR); for (String flag : flagArray) { if ("UNIX_LINES".equals(flag)) { flagsToUse |= Pattern.UNIX_LINES; } else if ("CASE_INSENSITIVE".equals(flag)) { flagsToUse |= Pattern.CASE_INSENSITIVE; } else if ("COMMENTS".equals(flag)) { flagsToUse |= Pattern.COMMENTS; } else if ("MULTILINE".equals(flag)) { flagsToUse |= Pattern.MULTILINE; } else if ("LITERAL".equals(flag)) { flagsToUse |= Pattern.LITERAL; } else if ("DOTALL".equals(flag)) { flagsToUse |= Pattern.DOTALL; } else if ("UNICODE_CASE".equals(flag)) { flagsToUse |= Pattern.UNICODE_CASE; } else if ("CANON_EQ".equals(flag)) { flagsToUse |= Pattern.CANON_EQ; } else {// w ww.j a va 2 s . c o m throw new IllegalArgumentException("Unknown flag: " + flag); } } return flagsToUse; }
From source file:org.apache.james.transport.mailets.PatternExtractor.java
private int extractOptions(String optionsAsString) { int options = 0; if (optionsAsString.contains("i")) { options |= Pattern.CASE_INSENSITIVE; }// ww w.ja v a 2 s. c o m if (optionsAsString.contains("m")) { options |= Pattern.MULTILINE; } if (optionsAsString.contains("s")) { options |= Pattern.DOTALL; } return options; }
From source file:TelnetTest.java
public void testPs() throws IOException { int maxIter = 2; for (int i = 0; i < maxIter; i++) { os.write("ps\r\n".getBytes()); os.flush();/*from w w w . j a va2s . c o m*/ String s = readUntil(is, prompt); s = s.substring(0, s.indexOf(prompt)); System.out.println(s); System.out.println("iteration " + (i + 1) + " of " + maxIter); Pattern p = Pattern.compile(".*ps.EXE\\[2000ee91\\]\\d\\d\\d\\d\r\n$", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); //Pattern.DOTALL => '.' includes end of line Matcher m = p.matcher(s); assertTrue(m.matches()); } }
From source file:org.clickframes.testframes.TestResultsParser.java
private ProjectTestResults parseResults(File firefoxDir) throws IOException { ProjectTestResults projectTestResults = new ProjectTestResults(); int totalPassed = 0; int totalFailed = 0; for (File suiteResultsFile : firefoxDir.listFiles()) { if (!suiteResultsFile.getName().endsWith("_result.html")) { continue; }//from w w w . ja va 2 s. c o m String suiteResultsFileContents = FileUtils.readFileToString(suiteResultsFile); /** * <table> * <tr> * <td>result:</td> * <td>failed</td> */ Matcher m1 = Pattern .compile("^.*<table>\\s*<tr>\\s*<td>\\s*result:</td>\\s*<td>(failed|passed)</td>.*$", Pattern.DOTALL) .matcher(suiteResultsFileContents); if (!m1.matches()) { throw new RuntimeException( "Invalid file found in the test results directory: " + suiteResultsFile.getAbsolutePath()); } if (m1.group(1).equals("passed")) { totalPassed++; } else { totalFailed++; } } projectTestResults.setFailedCount(totalFailed); projectTestResults.setPassedCount(totalPassed); return projectTestResults; }
From source file:de.blizzy.documentr.markdown.macro.impl.FlattrMacroTest.java
@Test public void getHtml() { String html = macro.getHtml(macroContext); @SuppressWarnings("nls") String re = "^<a href=\"([^\"]+)\">" + "<img src=\"https://api\\.flattr\\.com/button/flattr-badge-large\\.png\"/>" + "</a>$"; //$NON-NLS-2$ assertRE(re, html);//from www . j a v a2 s .c o m Matcher matcher = Pattern.compile(re, Pattern.DOTALL).matcher(html); matcher.find(); String url = StringEscapeUtils.unescapeHtml4(matcher.group(1)); UriComponents components = UriComponentsBuilder.fromHttpUrl(url).build(); assertEquals("https", components.getScheme()); //$NON-NLS-1$ assertEquals("flattr.com", components.getHost()); //$NON-NLS-1$ assertEquals(-1, components.getPort()); assertEquals("/submit/auto", components.getPath()); //$NON-NLS-1$ MultiValueMap<String, String> params = components.getQueryParams(); assertEquals(FLATTR_USER_ID, params.getFirst("user_id")); //$NON-NLS-1$ assertEquals(PAGE_URL, params.getFirst("url")); //$NON-NLS-1$ assertEquals(PAGE_TITLE, params.getFirst("title")); //$NON-NLS-1$ assertEquals("text", params.getFirst("category")); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue(params.getFirst("tags").equals(TAG_1 + "," + TAG_2) || //$NON-NLS-1$ //$NON-NLS-2$ params.getFirst("tags").equals(TAG_2 + "," + TAG_1)); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:pl.otros.logview.gui.message.pattern.PropertyPatternMessageColorizer.java
public void init(InputStream in) throws ConfigurationException { propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setDelimiterParsingDisabled(true); propertiesConfiguration.load(in, "UTF-8"); configuration = new DataConfiguration(propertiesConfiguration); configuration.setDelimiterParsingDisabled(true); String pa = configuration.getString(PROP_PATTERN); int flags = 0; flags = flags | (configuration.getBoolean(PROP_PATTERN_CANON_EQ, false) ? Pattern.CANON_EQ : 0); flags = flags/*from w w w . j a v a 2 s.c om*/ | (configuration.getBoolean(PROP_PATTERN_CASE_INSENSITIVE, false) ? Pattern.CASE_INSENSITIVE : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_COMMENTS, false) ? Pattern.COMMENTS : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_DOTALL, false) ? Pattern.DOTALL : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_LITERAL, false) ? Pattern.LITERAL : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_MULTILINE, false) ? Pattern.MULTILINE : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_UNICODE_CASE, false) ? Pattern.UNICODE_CASE : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_UNIX_LINES, false) ? Pattern.UNIX_LINES : 0); pattern = Pattern.compile(pa, flags); groupCount = countGroups(pattern); name = configuration.getString(PROP_NAME, "NAME NOT SET!"); description = configuration.getString(PROP_DESCRIPTION, "DESCRIPTION NOT SET!"); testMessage = configuration.getString(PROP_TEST_MESSAGE, ""); version = configuration.getInt(PROP_VERSION, 1); }
From source file:com.bealearts.template.SimpleTemplate.java
/** * Parse the template//from w ww . j a v a 2s .c o m */ private void parseTemplate(String content) { Pattern pattern = Pattern.compile( "<!--\\s*(BEGIN|END)\\s*:\\s*(\\w+)\\s*-->(.*?)(?=(?:<!--\\s*(?:BEGIN|END)\\s*:\\s*\\w+\\s*-->)|(?:\\s*$))", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); Matcher matcher = pattern.matcher(content); BlockContent currentBlock = null; String currentBlockPath = ""; while (matcher.find()) { if (matcher.group(1).equalsIgnoreCase("BEGIN")) { if (currentBlock == null) currentBlock = new BlockContent(); else currentBlock = (BlockContent) currentBlock.addContentItem(new BlockContent()); currentBlock.setName(matcher.group(2)); if (currentBlockPath.equals("")) currentBlockPath = currentBlock.getName(); else currentBlockPath += "." + currentBlock.getName(); this.blockMap.put(currentBlockPath, currentBlock); } else if (matcher.group(1).equalsIgnoreCase("END")) { currentBlock = currentBlock.getParent(); if (currentBlock != null) currentBlockPath = currentBlockPath.substring(0, currentBlockPath.lastIndexOf(".")); } if (currentBlock != null && matcher.group(3) != null && !matcher.group(3).equals("")) currentBlock.addContentItem(new TextContent(matcher.group(3))); } }
From source file:mojo.core.test.XStreamTest.java
private void assertElement(String xml, String tag, boolean closed) { String regex = ".*<" + tag + "(\\s+\\w+=[\"'].*[\"']\\s*)?" + (closed ? "/" : "") + ">.*"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); // System.out.println("Pattern: " + pattern); assertTrue(pattern.matcher(xml).matches()); }
From source file:com.edgenius.wiki.render.filter.MacroFilter.java
public void init() { pairedMacroProvider.compile(FilterRegxConstants.PAIRED_MACRO, Pattern.DOTALL); singleMacroProvider.compile(FilterRegxConstants.SINGLE_MACRO, Pattern.MULTILINE); Collection<Macro> list = macroMgr.getImmutableContentMacros(); for (Macro macro : list) { String identifier = macro.getHTMLIdentifier(); immutableHTMLIds.addAll(RenderUtil.parseHtmlIdentifier(identifier)); }/*from w w w .j a v a 2s . co m*/ }