List of usage examples for java.util.regex Matcher group
public String group(String name)
From source file:Main.java
public static String parseCustomProxyClassName(String customProxyClassName, String originClassName, String targetClassName) { mCustomProxyClassName = customProxyClassName; String templete = "^(.*)(\\$[O|T])(.*)(\\$[O|T])(.*)$"; Pattern compile = Pattern.compile(templete); Matcher matcher = compile.matcher(mCustomProxyClassName); if (!matcher.matches()) { printNotMatchErrorMessage();// ww w . ja v a 2 s. c om } String group2 = matcher.group(2); String group4 = matcher.group(4); if (group2.matches("\\$[O]") && group4.matches("\\$[T]")) { group2 = originClassName; group4 = targetClassName; } else if (group2.matches("\\$[T]") && group4.matches("\\$[O]")) { group2 = targetClassName; group4 = originClassName; } else { printNotMatchErrorMessage(); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(matcher.group(1)); stringBuilder.append(group2); stringBuilder.append(matcher.group(3)); stringBuilder.append(group4); stringBuilder.append(matcher.group(5)); return stringBuilder.toString(); }
From source file:fi.hsl.parkandride.core.domain.PredictionRequest.java
private static Duration parseRelativeTime(String relativeTime) { Matcher matcher = java.util.regex.Pattern.compile("(?:(\\d+):)?(\\d+)").matcher(relativeTime); if (matcher.matches()) { int hours = parseOptionalInt(matcher.group(1)); int minutes = Integer.parseInt(matcher.group(2)); return standardHours(hours).plus(standardMinutes(minutes)); } else {/*from w ww . ja v a 2 s . c om*/ return Duration.ZERO; } }
From source file:com.github.fritaly.svngraph.Utils.java
public static String getBranchName(String path) { final Matcher matcher = BRANCH_PATTERN.matcher(path); return matcher.matches() ? matcher.group(1) : null; }
From source file:com.github.fritaly.svngraph.Utils.java
public static String getModule(String path) { final Matcher matcher = MODULE_PATTERN.matcher(path); return matcher.matches() ? matcher.group(1) : null; }
From source file:gov.nih.nci.ncicb.tcga.dcc.dam.usage.UsageLoggerFileImplFastTest.java
public static Map<String, Map<String, String>> parseLog(UsageLoggerFileImpl logger) throws IOException { BufferedReader logFile = null; try {// ww w .j a va 2 s . com Map<String, Map<String, String>> log = new HashMap<String, Map<String, String>>(); //noinspection IOResourceOpenedButNotSafelyClosed logFile = new BufferedReader(new FileReader(logger.getFile())); String line = logFile.readLine(); Pattern actionPattern = Pattern.compile("^\\[(.+)\\](.+)=(.*)@(.+)$"); while (line != null) { Matcher m = actionPattern.matcher(line); if (m.matches()) { String sessionId = m.group(1); String actionName = m.group(2); String value = m.group(3); String date = m.group(4); if (value.length() == 0) { value = date; } Map<String, String> sessionLog = log.get(sessionId); if (sessionLog == null) { sessionLog = new HashMap<String, String>(); log.put(sessionId, sessionLog); } sessionLog.put(actionName, value); } line = logFile.readLine(); } return log; } finally { IOUtils.closeQuietly(logFile); } }
From source file:iox.refused.jhp.JHP_Parser.java
private static void compile(StringBuffer sb, String src) { Matcher m = TEXTLET.matcher(src); while (m.find()) { String name = BSLASHES.matcher(StringEscapeUtils.escapeJava(m.group(2))).replaceAll("\\\\\\\\"); m.appendReplacement(sb, "echo(\"" + name + "\");\n"); }//from w w w.j av a 2s . c o m m.appendTail(sb); }
From source file:com.art4ul.jcoon.util.HttpRequestUtil.java
public static void addKeyValueParams(Context context, String[] stringArray, AddingStatagy addingStatagy) { if (stringArray != null) { Pattern pattern = Pattern.compile(KEY_VALUE_REGEX_PATTERN); for (String str : stringArray) { Matcher matcher = pattern.matcher(str); while (matcher.find()) { if (matcher.groupCount() == 2) { String headerName = matcher.group(1); String headerValue = matcher.group(2); addingStatagy.add(headerName.trim(), headerValue.trim()); //context.getHttpHeaders().add(headerName.trim(), headerValue.trim()); }/*w ww .j a v a2 s. co m*/ } } } }
From source file:com.johnson.grab.browser.HttpClientUtil.java
private static String getPageEncoding(HttpResponse response) { Header contentType = response.getEntity().getContentType(); if (contentType == null || StringUtil.isEmpty(contentType.getValue())) { return null; }// w w w.ja v a 2s . com Matcher matcher = PATTERN_HTML_CHARSET.matcher(contentType.getValue()); if (matcher.find()) { return matcher.group(1); } return null; }
From source file:com.isotrol.impe3.extensions.wurfl.WURFLDeviceCapabilitiesProvider.java
private static String nameSpaceNumber(String header) { final Matcher matcher = NAMESPACE_NUMBER_PATTERN.matcher(header); return matcher.matches() ? matcher.group(1) : null; }
From source file:com.qmetry.qaf.automation.util.LocatorUtil.java
private static String parseParameters(String str) { try {/*from w ww. ja v a 2 s . com*/ Pattern p = Pattern.compile("\\$\\{([^}]+)\\}", Pattern.MULTILINE); Matcher m = p.matcher(str); while (m.find()) { String param = m.group(1); if (ConfigurationManager.getBundle().containsKey(param)) { str = str.replaceAll("\\$\\{" + param + "\\}", ConfigurationManager.getBundle().getString(param)); } } } catch (Exception e) { System.err.println("Unable to parse: " + str); e.printStackTrace(); } return str; }