List of usage examples for java.util.regex Matcher find
public boolean find()
From source file:ch.systemsx.cisd.openbis.generic.shared.translator.FilterTranslator.java
static Set<String> extractColumns(String expression) { Pattern parameterPattern = Pattern.compile(COLUMN_PATTERN); Set<String> list = new HashSet<String>(); Matcher matcher = parameterPattern.matcher(expression); while (matcher.find()) { String group = matcher.group(); list.add(group.substring(4, group.length() - 1)); }// ww w. ja v a 2 s . c o m return list; }
From source file:ch.systemsx.cisd.openbis.generic.shared.translator.FilterTranslator.java
static Set<String> extractParameters(String expression) { Pattern parameterPattern = Pattern.compile(PARAMETER_PATTERN); Set<String> list = new HashSet<String>(); Matcher matcher = parameterPattern.matcher(expression); while (matcher.find()) { String group = matcher.group(); list.add(group.substring(2, group.length() - 1)); }// w ww. j a va 2 s . c o m return list; }
From source file:com.nhncorp.lucy.security.xss.XssPreventer.java
/** * ? XSS({@code Cross Site Scripting}) ?? ? * ? .//from www . j ava 2 s. c om * ? XssFilter, XssSaxFilter ??? ??. * * @param dirty * XSS({@code Cross Site Scripting})? ?? . * @return . */ public static String escape(String dirty) { String clean = StringEscapeUtils.escapeHtml4(dirty); if (clean == null) { return null; } Matcher matcher = escapePattern.matcher(clean); if (matcher.find()) { return matcher.replaceAll("'"); } return clean; }
From source file:Main.java
/** Gets all linearDistributions as lists of String. */ public static List<String> getLinearDistributions(String qiesl) { Matcher m = LINEAR_DISTRIUBTIONS.matcher(qiesl); List<String> result = new ArrayList<String>(); while (m.find()) { result.add(m.group());/*from w w w.j a v a2 s. c om*/ } return result; }
From source file:Main.java
public static String camelCaseToSnakeCase(String camelCase) { List<String> tokens = new ArrayList<>(); Matcher matcher = PATTERN.matcher(camelCase); String acronym = ""; while (matcher.find()) { String found = matcher.group(); if (found.matches("^[A-Z]$")) { acronym += found;//w ww. ja v a2s . c o m } else { if (acronym.length() > 0) { // we have an acronym to add before we continue tokens.add(acronym); acronym = ""; } tokens.add(found.toLowerCase()); } } if (acronym.length() > 0) { tokens.add(acronym); } if (tokens.size() > 0) { StringBuilder sb = new StringBuilder(tokens.remove(0)); for (String s : tokens) { sb.append("_").append(s); } return sb.toString(); } else { return camelCase; } }