List of usage examples for java.util.regex Matcher group
public String group(String name)
From source file:Main.java
public static String getNumberFromString(String text) { Pattern p = Pattern.compile("(\\d+)"); Matcher m = p.matcher(text); if (m.find()) { return (m.group(1)); }/* w w w. j a va2 s. c om*/ return ""; }
From source file:Main.java
private static String extractPattern(String string, String pattern, int group) { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(string); if (m.find()) { return m.group(group); } else {/*from w w w .ja v a 2 s . co m*/ return null; } }
From source file:com.enonic.cms.business.localization.resource.LocalizationResourceBundleUtils.java
private static String getLanguageFromMatcher(Matcher matcher) { return matcher.group(1); }
From source file:com.enonic.cms.business.localization.resource.LocalizationResourceBundleUtils.java
private static String getCountryFromMatcher(Matcher matcher) { return matcher.group(3); }
From source file:com.enonic.cms.business.localization.resource.LocalizationResourceBundleUtils.java
private static String getVariantFromMatcher(Matcher matcher) { return matcher.group(5); }
From source file:Main.java
public static String getIdInUrl(String type, String url) { Pattern p = Pattern.compile("/" + type + "/(\\w+)(\\?|/)*"); Matcher matcher = p.matcher(url); if (matcher.find()) { return matcher.group(1); }//from w ww .java2s. c o m return ""; }
From source file:Main.java
public static ArrayList<String> getMatchString(String origin, String pattern, int groupId) { ArrayList<String> datas = new ArrayList<>(); Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(origin); while (m.find()) { datas.add(m.group(groupId)); }/* w w w. j a va 2s . com*/ return datas; }
From source file:Main.java
public static String u2s(String u) { Pattern pat = Pattern.compile("[\\\\U|\\\\u]([0-9a-fA-F]{4})"); Matcher mat = pat.matcher(u); while (mat.find()) { String HEX = mat.group(1); char v = (char) (Integer.parseInt(HEX.toUpperCase(), 16)); mat = pat.matcher(u = u.replace("\\" + mat.group(), "" + v)); }/*from ww w.j a v a 2 s . co m*/ return u; }
From source file:Main.java
public static String getStringDigits(String text) { text = null == text ? "" : text; StringBuilder digitList = new StringBuilder(""); Pattern p = Pattern.compile("(\\d+)"); Matcher m = p.matcher(text); while (m.find()) { String find = m.group(1).toString(); digitList.append(find);//from w w w .ja va 2s . c o m } return digitList.toString(); }
From source file:Main.java
public static List getHtmlTagContent(String html, String tagname) { List resultList = new ArrayList(); Pattern p = Pattern.compile("<" + tagname + ">([^</" + tagname + ">]*)"); Matcher m = p.matcher(html); while (m.find()) { resultList.add(m.group(1)); }/*from www. java 2 s. c om*/ return resultList; }