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:com.mirth.connect.client.ui.util.SQLParserUtil.java
public String[] Parse() { try {/* w w w . jav a2s. com*/ List<String> varList = new ArrayList<String>(); Pattern pattern = Pattern.compile(SQL_PATTERN, Pattern.MULTILINE); Matcher matcher = pattern.matcher(_sqlStatement); while (matcher.find()) { String key = matcher.group(); int fromClause = key.toUpperCase().indexOf(" FROM "); if (fromClause > 0) { String columnText = key.substring(6, fromClause).replaceAll("`", ""); columnText = removeNestedFunctions(columnText, 0); String[] vars = columnText.split(","); for (int i = 0; i < vars.length; i++) { if (vars[i].length() > 0) { for (int j = 0; j < keywords.length; j++) { int index = vars[i].toUpperCase().indexOf(keywords[j]); int size = (keywords[j]).length(); if (index != -1) { if (index > 0) { if (vars[i].substring(index - 1, index).equals(" ") && (vars[i].length() == index + size || vars[i] .substring(index + size, index + size + 1).equals(" "))) { vars[i] = vars[i].replaceAll(vars[i].substring(index, index + size), ""); } } else if (vars[i].length() == index + size || vars[i].substring(index + size, index + size + 1).equals(" ")) { vars[i] = vars[i].replaceAll(vars[i].substring(index, index + size), ""); } } } if (vars[i].length() > 0) { String var; if (vars[i].toUpperCase().indexOf(" AS ") != -1) { var = (vars[i].substring(vars[i].toUpperCase().indexOf(" AS ") + 4)) .replaceAll(" ", "").replaceAll("\\(", "").replaceAll("\\)", ""); } else if (vars[i].indexOf('(') != -1 || vars[i].indexOf(')') != -1 || vars[i].indexOf('}') != -1 || vars[i].indexOf('{') != -1 || vars[i].indexOf('*') != -1) { continue; } else { vars[i] = vars[i].trim(); var = vars[i].replaceAll(" ", "").replaceAll("\\(", "").replaceAll("\\)", ""); if (var.lastIndexOf('.') != -1) { var = var.substring(var.lastIndexOf('.') + 1); } } if ((StringUtils.substring(var, 0, 1).equals("\"") && StringUtils.substring(var, -1).equals("\"")) || (StringUtils.substring(var, 0, 1).equals("'") && StringUtils.substring(var, -1).equals("'"))) { var = StringUtils.substring(var, 1, -1); } if ((StringUtils.substring(var, 0, 2).equals("\\\"") && StringUtils.substring(var, -2).equals("\\\"")) || (StringUtils.substring(var, 0, 2).equals("\\'") && StringUtils.substring(var, -2).equals("\\'"))) { var = StringUtils.substring(var, 2, -2); } var = StringUtils.lowerCase(var); varList.add(var); } } } } } return varList.toArray(new String[varList.size()]); } catch (Exception e) { logger.error(e); } return new String[0]; }
From source file:org.eclipse.rdf4j.rio.rdfxml.RDFXMLPrettyWriterBackgroundTest.java
/** * Extract lines that start an rdf element so basic assertions can be made. *///from w ww. jav a 2s . c o m private static List<String> rdfOpenTags(String s) throws IOException { String withoutSpaces = Pattern.compile("^\\s+", Pattern.MULTILINE).matcher(s).replaceAll(""); List<String> rdfLines = new ArrayList<String>(); for (String l : IOUtils.readLines(new StringReader(withoutSpaces))) { if (l.startsWith("<rdf:")) { rdfLines.add(l.replaceAll(" .*", "")); } } return rdfLines; }
From source file:RegexProperties.java
public void load(FileInputStream inStream) throws IOException, PatternSyntaxException { FileChannel fc = inStream.getChannel(); ByteBuffer bb = ByteBuffer.allocate((int) fc.size()); fc.read(bb);/*from ww w . ja v a 2 s.c o m*/ bb.flip(); String fileContent = new String(bb.array()); Pattern pattern = Pattern.compile("^(.*)$", Pattern.MULTILINE); Matcher matcher = pattern.matcher(fileContent); while (matcher.find()) { String line = matcher.group(1); if (line != null && !"".equals(line.trim()) && !line.startsWith("#") && !line.startsWith("!")) { String keyValue[] = null; if (line.indexOf("=") > 0) keyValue = line.split("=", 2); else keyValue = line.split(":", 2); if (keyValue != null) { super.put(keyValue[0].trim(), keyValue[1]); } } } fc = null; bb = null; }
From source file:nl.ordina.bag.etl.mail.handler.MessageHandler.java
public void init() throws NoSuchAlgorithmException, KeyManagementException { urlPattern = Pattern.compile("(?im)^.*(" + urlRegEx + ").*$", Pattern.CASE_INSENSITIVE + Pattern.MULTILINE); }
From source file:org.projectforge.jira.JiraUtils.java
public static boolean hasJiraIssues(final String text) { if (StringUtils.isBlank(text)) { return false; }//from w w w . j a va 2 s .co m final Pattern p = Pattern.compile(PATTERN, Pattern.MULTILINE); final Matcher m = p.matcher(text); return m.find(); }
From source file:com.edgenius.wiki.render.filter.UrlFilter.java
public void init() { regexProvider.compile(getRegex(), Pattern.MULTILINE); formatter = new MessageFormat(getReplacement()); }
From source file:ubic.gemma.core.loader.genome.FastaParser.java
public FastaParser() { String patternStr = "^(.*)$"; pattern = Pattern.compile(patternStr, Pattern.MULTILINE); }
From source file:org.faster.util.Strings.java
public static Pattern getPattern(String uncompiledPattern, boolean regex) { String key = uncompiledPattern + regex; Pattern pattern = patternMap.get(key); if (pattern == null) { synchronized (patternMap) { pattern = patternMap.get(key); if (pattern == null) { if (regex) { pattern = Pattern.compile(uncompiledPattern, Pattern.MULTILINE); } else { pattern = Pattern.compile(uncompiledPattern, Pattern.LITERAL); }/*from ww w . jav a2s . c o m*/ patternMap.put(key, pattern); } } } return pattern; }
From source file:com.edgenius.wiki.render.filter.HeadingFilter.java
public void init() { regexProvider.compile(getRegex(), Pattern.MULTILINE); formatter = new MessageFormat(""); formatter.applyPattern(getReplacement()); }
From source file:org.onehippo.cms7.essentials.dashboard.utils.GlobalUtils.java
/** * * Replaces {@code #placeholder#} variable with string replacement provided * * @param input input string/*w w w.j a v a2s.c o m*/ * @param placeholder placeholder name * @param replacement replacement string * @return input string replaced with replacements */ public static String replacePlaceholders(final String input, final String placeholder, final String replacement) { if (Strings.isNullOrEmpty(input)) { return ""; } final StringBuffer buffer = new StringBuffer(input); try { final Pattern pattern = Pattern.compile("(#" + placeholder + "#)", Pattern.MULTILINE); Matcher matcher = pattern.matcher(buffer); while (matcher.find()) { buffer.replace(matcher.start(), matcher.end(), replacement); } } catch (Exception ignore) { //ignore } return buffer.toString(); }