List of usage examples for java.util.regex Matcher group
public String group(String name)
From source file:Main.java
public static String getAttributeNameFromColName(String tableName) { Pattern p = Pattern.compile("_+(\\w?)"); Matcher m = p.matcher(tableName); StringBuffer sb = new StringBuffer(); while (m.find()) { if (m.start() != 0) m.appendReplacement(sb, m.group(1).toUpperCase()); else//from w ww .ja v a 2s . c om m.appendReplacement(sb, m.group(1).toLowerCase()); } m.appendTail(sb); return sb.toString(); }
From source file:com.adaptc.mws.plugins.testing.support.PluginsResourceUtils.java
/** * Returns the class name for a resource. * * @param path The path to check//from w ww .jav a2 s. c o m * @return The class name or null if it doesn't exist */ public static String getClassName(String path) { for (Pattern pattern : patterns) { Matcher m = pattern.matcher(path); if (m.find()) { return m.group(1).replaceAll("[/\\\\]", "."); } } return null; }
From source file:com.ignorelist.kassandra.steam.scraper.LibraryScanner.java
public static Set<Long> findGames(Path path) throws IOException { Set<Long> gameIds = new HashSet<>(); DirectoryStream<Path> directoryStream = null; try {//from w w w . ja v a2 s. c o m directoryStream = Files.newDirectoryStream(path, new DirectoryStream.Filter<Path>() { @Override public boolean accept(Path entry) throws IOException { return Files.isRegularFile(entry); } }); for (Path f : directoryStream) { final String fileName = f.getFileName().toString(); Matcher matcher = PATTERN.matcher(fileName); if (matcher.matches()) { gameIds.add(Long.parseLong(matcher.group(1))); } } return gameIds; } finally { IOUtils.closeQuietly(directoryStream); } }
From source file:net.longfalcon.newsj.util.ParseUtil.java
public static String parseRageId(String nfoText) { Matcher matcher = _ragePattern.matcher(nfoText); if (matcher.find()) { try {/*from w w w . jav a 2 s . co m*/ String rageIdString = matcher.group(1); return rageIdString.trim(); } catch (Exception e) { _log.debug(e); } } return null; }
From source file:Main.java
public static String findTitle(File f) { if (titlePattern == null) { initPattern();// ww w . java 2 s . c o m } try { FileChannel fc = new FileInputStream(f).getChannel(); MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); CharBuffer cb = Charset.forName("8859_1").newDecoder().decode(bb); //$NON-NLS-1$ Matcher m = titlePattern.matcher(cb); String title = null; if (m.find()) { title = m.group(1); } return title; } catch (IOException e) { return null; } }
From source file:com.hygenics.parser.Properties.java
/** * Get a property from a key string//from w ww . j a va 2s .c o m * @param k They key containing. * @return The string with the key replaced. */ public static String getProperty(String k) { String rval = k; if (k != null && props != null) { if (k.contains("property:")) { Pattern p = Pattern.compile("property:[^\\s]+"); Matcher m = p.matcher(k); while (m.find()) { rval = rval.replace(m.group(0), System.getProperty(m.group(0).replace("property:", ""))); } return rval; } } return rval; }
From source file:emily.util.YTUtil.java
/** * Extracts the videocode from an url/*from ww w . ja v a2 s. c om*/ * * @param url youtube link * @return videocode */ public static String extractCodeFromUrl(String url) { Matcher matcher = yturl.matcher(url); if (matcher.find()) { if (matcher.group(1) != null) { return matcher.group(1); } } return url; }
From source file:Main.java
/** * Decode the setup type integer from the Bluetooth device name. * @param bluetoothName/*from www. j a v a2s . c o m*/ * @return The integer value of the setup code, or -1 if no code is present. */ public static int getSetupType(String bluetoothName) { Matcher matcher = NAME_PATTERN.matcher(bluetoothName); if (!matcher.matches()) { return -1; } String typeStr = matcher.group(1); if (typeStr != null) { try { return Integer.parseInt(typeStr); } catch (NumberFormatException e) { return -1; } } else { return -1; } }
From source file:com.cognifide.slice.util.InjectorNameUtil.java
/** * This util provides injector name for a given resource. The name is read from second part of the * resource type, i.e. part after /apps/. For instance, for /apps/myapp/someresource, it will return * <code>myapp</code> <br> * <br>//from w w w. ja v a2s . c o m * Please note that this method is deprecated and it doesn't support injectors registered for a given path * (with use of {@link InjectorRunner#setInjectorPath(String)}) * * @deprecated use {@link InjectorsRepository#getInjectorNameForResource(String)} instead * * @param resourceType resource type to take the injector name from * @return injector name, always second part of the resource type */ @Deprecated public static String getFromResourceType(String resourceType) { String injectorName = null; if (StringUtils.isNotEmpty(resourceType)) { Pattern pattern = RESOURCE_TYPE_PATTERN; Matcher matcher = pattern.matcher(resourceType); if (matcher.matches()) { injectorName = matcher.group(2); } } return injectorName; }
From source file:Main.java
private static String renderEmail(String bodyHtml) { StringBuffer bodyStringBuffer = new StringBuffer(); Matcher matcherEmailContent = patternTagTitle.matcher(bodyHtml); while (matcherEmailContent.find()) { String processContent = matcherEmailContent.group(1); String htmlContent = matcherEmailContent.group(2); if (htmlContent.equalsIgnoreCase("</script>") || htmlContent.equalsIgnoreCase("</a>")) { matcherEmailContent.appendReplacement(bodyStringBuffer, processContent + htmlContent); } else {//from w ww. j a v a2s . c o m String emailContentHasProcessed = makeEmailHerf(processContent); matcherEmailContent.appendReplacement(bodyStringBuffer, emailContentHasProcessed + htmlContent); } } matcherEmailContent.appendTail(bodyStringBuffer); return bodyStringBuffer.toString(); }