List of usage examples for java.util.regex Pattern MULTILINE
int MULTILINE
To view the source code for java.util.regex Pattern MULTILINE.
Click Source Link
From source file:org.j2free.util.HtmlFilter.java
/** * * @param text/*from w ww .j ava 2 s . c o m*/ * @return */ public String strictFilter(String text) { if (text == null || text.equals("")) return text; Pattern p0 = Pattern.compile(HTML_START, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); Pattern p1 = Pattern.compile(HTML_END, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); Matcher m0 = p0.matcher(text); Matcher m1 = p1.matcher(m0.replaceAll("")); return m1.replaceAll(""); }
From source file:Normalization.TextNormalization.java
public String removeUrlsFromString(String content) { String utf8tweet = ""; try {/*from w w w .ja v a 2 s.c om*/ byte[] utf8Bytes = content.getBytes("UTF-8"); utf8tweet = new String(utf8Bytes, "UTF-8"); } catch (UnsupportedEncodingException e) { } final String regex = "(https?|ftp|file|pic|www)[:|.][-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]"; final Pattern unicodeOutliers = Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); Matcher unicodeOutlierMatcher = unicodeOutliers.matcher(utf8tweet); utf8tweet = unicodeOutlierMatcher.replaceAll(""); return utf8tweet; }
From source file:org.springframework.data.semantic.query.AbstractSparqlQuery.java
private String removeComments(String text) { return Pattern.compile("^(\\s*)#.*$", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE).matcher(text) .replaceAll(""); }
From source file:org.kalypso.ogc.gml.outline.nodes.FeatureThemeNode.java
private IThemeNode findImageChild(final IThemeNode[] children) { final String externIconUrn = getElement().getLegendIcon(); if (externIconUrn == null) { if (children.length == 0) return null; return children[0]; }//from ww w . j a v a 2 s. c om /* Check, if it is a special URN. */ final Pattern p = Pattern.compile("^urn:kalypso:map:theme:swtimage:style:(.*):rule:(.*)$", //$NON-NLS-1$ Pattern.MULTILINE); final Matcher m = p.matcher(externIconUrn.trim()); if (!m.matches() || m.groupCount() != 2) return null; /* A special URN was defined. Evaluate it. */ final String styleName = m.group(1); final String ruleName = m.group(2); final IThemeNode themeNode = findObject(children, styleName); if (themeNode == null) return null; final Object[] ftsChildren = themeNode.getChildren(); return RuleNode.findObject(ftsChildren, ruleName); }
From source file:org.eclipse.rdf4j.repository.sparql.query.SPARQLOperation.java
protected Set<String> getBindingNames() { if (bindings.size() == 0) return Collections.EMPTY_SET; Set<String> names = new HashSet<String>(); String qry = operation;//from ww w. j a v a 2 s . co m int b = qry.indexOf('{'); String select = qry.substring(0, b); for (String name : bindings.getBindingNames()) { String replacement = getReplacement(bindings.getValue(name)); if (replacement != null) { String pattern = ".*[\\?\\$]" + name + "\\W.*"; if (Pattern.compile(pattern, Pattern.MULTILINE | Pattern.DOTALL).matcher(select).matches()) { names.add(name); } } } return names; }
From source file:org.jbpm.integration.console.shared.GuvnorConnectionUtils.java
public String getProcessImageURLFromGuvnor(String processId) { List<String> allPackages = getPackageNames(); for (String pkg : allPackages) { // query the package to get a list of all processes in this package List<String> allProcessesInPackage = getAllProcessesInPackage(pkg); // check each process to see if it has the matching id set for (String process : allProcessesInPackage) { String processContent = getProcessSourceContent(pkg, process); Pattern p = Pattern.compile("<\\S*process[\\s\\S]*id=\"" + processId + "\"", Pattern.MULTILINE); Matcher m = p.matcher(processContent); if (m.find()) { try { String imageBinaryURL = getGuvnorProtocol() + "://" + getGuvnorHost() + "/" + getGuvnorSubdomain() + "/org.drools.guvnor.Guvnor/package/" + pkg + "/LATEST/" + URLEncoder.encode(processId, "UTF-8") + "-image.png"; return imageBinaryURL; } catch (Exception e) { logger.error("Could not read process image: " + e.getMessage()); throw new RuntimeException("Could not read process image: " + e.getMessage()); }/*from w w w . j av a 2 s. co m*/ } } } logger.info("Did not find process image for: " + processId); return null; }
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 {//from ww w .j a va 2 s. c om throw new IllegalArgumentException("Unknown flag: " + flag); } } return flagsToUse; }
From source file:com.ebay.jetstream.event.processor.esper.EPL.java
/** * Parses a single String containing a semicolon delimited list of EPL statements. * * @param statementBlock//ww w . ja va 2 s .c o m * the String containing all statements, with each statement separated by a semicolon. */ public void setStatementBlock(String statementBlock) { // TODO: better stmt delimiter parsing (e.g. skip ';' in a string or comment) m_statements.clear(); m_statementsWithComments.clear(); String noncomment = ""; /** * This pattern removes statements with comments. */ if (statementBlock.contains("/*")) { Pattern p = Pattern.compile("/\\*(.*?)\\*/", Pattern.MULTILINE | Pattern.DOTALL); Matcher m = p.matcher(statementBlock); while (m.find()) { noncomment = m.replaceAll(""); } } else { noncomment = statementBlock; } String pattern = "(?s);(?=(?:(?:.*?(?<!\\\\)\"){2})*[^\"]*$)(?=(?:(?:.*?(?<!\\\\)'){2})*[^']*$)"; String[] stmts = noncomment.split(pattern, -1); for (String statement : stmts) { String trimmed = statement.trim(); if (trimmed.length() > 0) { m_statements.add(trimmed); } } }
From source file:fr.dudie.acrachilisync.handler.AcraToChiliprojectSyncHandler.java
/** * {@inheritDoc}/*from ww w . j av a 2 s .c o m*/ * * @see fr.dudie.acrachilisync.handler.AcraReportHandler#onNewReport(fr.dudie.acrachilisync.model.AcraReport) */ @Override public void onNewReport(final AcraReport pReport) throws SynchronizationException { final Issue issue = new Issue(); final Project project = new Project(); project.setId(ConfigurationManager.getInstance().CHILIPROJECT_PROJECT_ID); issue.setProject(project); final Tracker tracker = new Tracker(); tracker.setId(ConfigurationManager.getInstance().CHILIPROJECT_TRACKER_ID); issue.setTracker(tracker); final CustomField md5CustomField = new CustomField(); md5CustomField.setId(ConfigurationManager.getInstance().CHILIPROJECT_STACKTRACE_MD5_CF_ID); md5CustomField.setValue(pReport.getStacktraceMD5()); issue.getCustomFields().add(md5CustomField); final String stack = pReport.getValue(AcraReportHeader.STACK_TRACE); final IssueDescriptionBuilder description = new IssueDescriptionBuilder(stack); description.addOccurrence(IssueDescriptionUtils.toErrorOccurrence(pReport)); final Matcher m = Pattern.compile("(.*)$", Pattern.MULTILINE).matcher(stack); m.find(); issue.setSubject(m.group()); issue.setDescription(description.build()); try { redmineClient.createIssue(String.valueOf(ConfigurationManager.getInstance().CHILIPROJECT_PROJECT_ID), issue); } catch (final Exception e) { pReport.setStatus(SyncStatus.FAILURE); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Failure while creating issue: \n{}", ToStringBuilder.reflectionToString(issue, ToStringStyle.MULTI_LINE_STYLE)); } throw new SynchronizationException("Unable to create issue for ACRA report: " + pReport.getId(), e); } pReport.setStatus(SyncStatus.SUCCESS); }
From source file:com.conx.logistics.kernel.bpm.impl.jbpm.core.mock.BPMGuvnorUtil.java
public String getProcessImageURLFromGuvnor(String processId) { List<String> allPackages = getPackageNames(); for (String pkg : allPackages) { // query the package to get a list of all processes in this package List<String> allProcessesInPackage = getAllProcessesInPackage(pkg); // check each process to see if it has the matching id set for (String process : allProcessesInPackage) { String processContent = getProcessSourceContent(pkg, process); Pattern p = Pattern.compile("<\\S*process[\\s\\S]*id=\"" + processId + "\"", Pattern.MULTILINE); Matcher m = p.matcher(processContent); if (m.find()) { try { String imageBinaryURL = getGuvnorProtocol() + "://" + getGuvnorHost() + "/" + getGuvnorSubdomain() + "/org.drools.guvnor.Guvnor/package/" + pkg + "/" + getGuvnorSnapshotName() + "/" + URLEncoder.encode(processId, "UTF-8") + "-image.png"; URL checkURL = new URL(imageBinaryURL); HttpURLConnection checkConnection = (HttpURLConnection) checkURL.openConnection(); checkConnection.setRequestMethod("GET"); checkConnection.setConnectTimeout(Integer.parseInt(getGuvnorConnectTimeout())); checkConnection.setReadTimeout(Integer.parseInt(getGuvnorReadTimeout())); applyAuth(checkConnection); checkConnection.connect(); if (checkConnection.getResponseCode() == 200) { return imageBinaryURL; }//from w w w . j a v a 2 s . co m } catch (Exception e) { logger.error("Could not read process image: " + e.getMessage()); throw new RuntimeException("Could not read process image: " + e.getMessage()); } } } } logger.info("Did not find process image for: " + processId); return null; }