List of usage examples for java.util.regex Matcher group
public String group()
From source file:cu.uci.uengine.utils.RegexUtils.java
public static int getDataSetNumber(File file) throws InvalidDataSetNameException { String baseName = FilenameUtils.getBaseName(file.getName()); Pattern p = Pattern.compile("\\d+$");//Digits at string end. Matcher m = p.matcher(baseName); if (!m.find()) { throw new InvalidDataSetNameException(String.format("DataSet %s is not a valid name.", baseName)); }//from ww w . j a va 2 s.c om int dataSetNumber = Integer.parseInt(m.group()); return dataSetNumber; }
From source file:io.curly.bloodhound.query.QueryParser.java
@NotNull static MultiValueMap<String, String> resolveMultiParameter(String query) { final MultiValueMap<String, String> multimap = new LinkedMultiValueMap<>(); convertToMap(query).forEach((key, value) -> { if (value.contains(L_CURLY) && value.contains(R_CURLY)) { Matcher matcher = Pattern.compile(REGEX_INNER_CURLY).matcher(value); if (matcher.find()) { String cleaned = cleanDelimiters(matcher.group()); if (cleaned.contains(COMMA)) { multimap.put(key, getCommaDelimitedValue(cleaned)); } else { multimap.put(key, getSpaceSplicedValue(cleaned)); }//from w w w .j a v a 2 s . co m } } else { multimap.add(key, unquote(value)); } }); return multimap; }
From source file:com.baidu.rigel.biplatform.ac.util.PlaceHolderUtils.java
/** * ????? abc/${1}/${2}/abc.action,?? ${1},${2} * /*from ww w.j a v a 2s. c om*/ * @param source ? * @return ???? */ public static List<String> getPlaceHolders(String source) { if (StringUtils.isBlank(source)) { throw new IllegalArgumentException("can not get place hode list by blank source"); } Pattern pattern = Pattern.compile("\\$\\{[^\\}]+\\}"); Matcher match = pattern.matcher(source); List<String> result = new ArrayList<String>(); while (match.find()) { result.add(match.group()); } return result; }
From source file:kr.pe.javarss.mybus.task.GBusPageParser.java
private static MyBus.Position parsePosition(Element e) { MyBus.Position p = new MyBus.Position(); List<Element> spans = e.getAllElements("span"); for (Element span : spans) { String css = span.getAttributeValue("class"); String content = span.getContent().toString(); if (css == null) { // <span>(711396)</span> p.licenseNumber = content;// w w w . j a v a2s . c o m } else if (css.equals("num1") || css.equals("num2")) { // <span class="num1">1 / 2 ?</span> // <span class="num2">3 / 7 ?</span> // <span class="num1">? </span> Matcher m = numberPattern.matcher(content); if (m.find()) { p.remainingCount = Integer.parseInt(m.group()); } if (m.find()) { p.timeToArrive = Integer.parseInt(m.group()); } //if (!m.matches()) { // p.otherInfo = content; //} } else { // <span class="narrival">? .</span> //p.otherInfo = content; } } return p; }
From source file:ccm.pay2spawn.configurator.HTMLGenerator.java
private static String replace(String text, Reward reward) throws IOException { while (true) { Matcher matcher = VAR.matcher(text); if (!matcher.find()) break; text = text.replace(matcher.group(), get(matcher.group(1), reward)); }//w w w . j a va 2 s .c om return text; }
From source file:com.quackware.handsfreemusic.Utility.java
public static CharSequence[][] retrieveYouTubeTitleAndUrl(String html) { ArrayList<String> links = new ArrayList<String>(); ArrayList<String> titles = new ArrayList<String>(); Pattern myPattern1 = Pattern.compile("<a href=\"rtsp.*?\\.3gp.*?\">"); Pattern myPattern2 = Pattern.compile("<a accesskey=.*?</a>"); Pattern myPattern3 = Pattern.compile(">.*?</a>"); Matcher myMatcher = myPattern1.matcher(html); while (myMatcher.find() && links.size() < 5) { links.add(myMatcher.group().replace("<a href=\"", "").replace("\">", "")); }//w ww. java 2 s. c om myMatcher = myPattern2.matcher(html); while (myMatcher.find() && titles.size() < 5) { Matcher myMatcher2 = myPattern3.matcher(myMatcher.group()); myMatcher2.find(); titles.add(myMatcher2.group().replace(">", "").replace("</a", "")); } CharSequence[][] searchResults = new CharSequence[2][links.size()]; for (int i = 0; i < links.size(); i++) { searchResults[0][i] = links.get(i); searchResults[1][i] = titles.get(i); } return searchResults; }