List of usage examples for java.util.regex Matcher group
public String group(String name)
From source file:fitnesse.responders.files.UploadResponder.java
public static String makeRelativeFilename(String name) { Matcher match = filenamePattern.matcher(name); if (match.find()) return match.group(2); else//from w w w .ja va 2 s . com return name; }
From source file:com.haulmont.cuba.core.global.filter.ParametersHelper.java
private static ParameterInfo parse(Matcher matcher) { boolean caseInsensitive = !StringUtils.isBlank(matcher.group(1)); final String param = matcher.group(2); return parse(param, caseInsensitive); }
From source file:Main.java
public static String getMD5FileName(String filePathName) { if (!TextUtils.isEmpty(filePathName)) { Matcher matcher = sPattern.matcher(filePathName); if (matcher.find()) { return matcher.group(1) + matcher.group(2); }//from w w w .j av a2s.co m } return getMD5Value(filePathName); }
From source file:Main.java
public static String getHrefInnerHtml(String href) { if (isEmpty(href)) { return ""; }//from w w w . j a v a2 s. co m String hrefReg = ".*<[\\s]*a[\\s]*.*>(.+?)<[\\s]*/a[\\s]*>.*"; Pattern hrefPattern = Pattern.compile(hrefReg, Pattern.CASE_INSENSITIVE); Matcher hrefMatcher = hrefPattern.matcher(href); if (hrefMatcher.matches()) { return hrefMatcher.group(1); } return href; }
From source file:Main.java
public static String getAccountType(Context context, long id, String name) { try {//from w w w. ja va 2s . c o m Cursor cur = context.getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI, new String[] { ContactsContract.RawContacts.ACCOUNT_TYPE, ContactsContract.RawContacts.ACCOUNT_NAME }, ContactsContract.RawContacts.CONTACT_ID + " = ?", new String[] { String.valueOf(id) }, null); if (cur != null) { String str = ""; while (cur.moveToNext()) { str += cur.getString(cur.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE)); } // Log.v("getAccountType", name+" => "+str); cur.close(); Matcher m = accountTypePattern.matcher(str); String last = ""; while (m.find()) { last = m.group(1); } return last; } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:org.jspringbot.keyword.expression.engine.function.StaticMethodUtils.java
public static Method getMethod(Class clazz, String methodSignature) { Matcher matcher = METHOD_SIGNATURE_PATTERN.matcher(methodSignature); if (matcher.find()) { String methodName = matcher.group(2); String parameterTypes = matcher.group(3); List<Class> types = new ArrayList<Class>(); for (String parameterType : StringUtils.split(parameterTypes, ',')) { ClassEditor editor = new ClassEditor(); editor.setAsText(parameterType); types.add((Class) editor.getValue()); }/* w ww . ja v a 2s .co m*/ return MethodUtils.getAccessibleMethod(clazz, methodName, types.toArray(new Class[types.size()])); } throw new IllegalStateException(String.format("Invalid method signature '%s' found.", methodSignature)); }
From source file:com.omertron.themoviedbapi.model.comparator.PersonCreditDateComparator.java
/** * locate a 4 digit year in a date string * * @param date/*from ww w.ja va 2 s . c o m*/ * @return */ private static int extractYear(String date) { int year = 0; Matcher m = YEAR_PATTERN.matcher(date); if (m.find()) { year = Integer.parseInt(m.group(1)); } // Give up and return 0 return year; }
From source file:Main.java
private static String renderTelephone(String bodyHtml) { StringBuffer bodyStringBuffer = new StringBuffer(); Matcher matcherTelContent = patternTagTitle.matcher(bodyHtml); while (matcherTelContent.find()) { String processContent = matcherTelContent.group(1); String htmlContent = matcherTelContent.group(2); if (htmlContent.equalsIgnoreCase("</script>") || htmlContent.equalsIgnoreCase("</a>")) { matcherTelContent.appendReplacement(bodyStringBuffer, processContent + htmlContent); } else {// ww w . j ava 2 s . c o m String telContentHasProcessed = makeTelNoHerf(processContent); matcherTelContent.appendReplacement(bodyStringBuffer, telContentHasProcessed + htmlContent); } } matcherTelContent.appendTail(bodyStringBuffer); return bodyStringBuffer.toString(); }
From source file:net.longfalcon.newsj.util.ParseUtil.java
public static String parseImdb(String nfoText) { Matcher matcher = _imdbPattern.matcher(nfoText); if (matcher.find()) { try {/*from www. ja v a 2 s . c o m*/ String imdbString = matcher.group(2); return imdbString.trim(); } catch (Exception e) { _log.debug(e); } } return null; }
From source file:net.alegen.datpass.cli.input.Command.java
private static List<String> split(String input) { List<String> matchList = new ArrayList<String>(); Pattern regex = Pattern.compile("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'"); Matcher regexMatcher = regex.matcher(input); while (regexMatcher.find()) { if (regexMatcher.group(1) != null) matchList.add(regexMatcher.group(1)); // Add double-quoted string without the quotes else if (regexMatcher.group(2) != null) matchList.add(regexMatcher.group(2)); // Add single-quoted string without the quotes else/*ww w .j a v a2 s . c o m*/ matchList.add(regexMatcher.group()); // Add unquoted word } return matchList; }