org.apache.regexp.RE.getParenCount()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中org.apache.regexp.RE.getParenCount方法的一些代码示例,展示了RE.getParenCount的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RE.getParenCount方法的具体详情如下:
包路径:org.apache.regexp.RE
类名称:RE
方法名:getParenCount

RE.getParenCount介绍

[英]Returns the number of parenthesized subexpressions available after a successful match.
[中]返回成功匹配后可用的括号子表达式数。

代码示例

代码示例来源:origin: org.jdom/jdom-contrib

/**
 * Dump parenthesized subexpressions found by a regular expression matcher object
 * @param r Matcher object with results to show
*/
static void showParens(RE r)
{
  // Loop through each paren
  for (int i = 0; i < r.getParenCount(); i++)
  {
    // Show paren register
    System.out.println("$" + i + " = " + r.getParen(i));
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-util

return null;
int n = re.getParenCount();
String[] list = new String[n];
list[0] = str;

代码示例来源:origin: org.apache.ant/ant-apache-regexp

/**
 * Returns a Vector of matched groups found in the argument.
 *
 * <p>Group 0 will be the full match, the rest are the
 * parenthesized subexpressions</p>.
 *
 * @param input the string to match against
 * @param options the regex options to use
 * @return the vector of groups
 * @throws BuildException on error
 */
@Override
public Vector<String> getGroups(String input, int options)
  throws BuildException {
  RE reg = getCompiledPattern(options);
  if (!matches(input, reg)) {
    return null;
  }
  Vector<String> v = new Vector<>();
  int cnt = reg.getParenCount();
  for (int i = 0; i < cnt; i++) {
    String match = reg.getParen(i);
    // treat non-matching groups as empty matches
    if (match == null) {
      match = "";
    }
    v.add(match);
  }
  return v;
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * Match the prepared pattern against the value returned by {@link #getMatchString(Map, Parameters)}.
 */
public Map preparedMatch(Object preparedPattern, Map objectModel, Parameters parameters) throws PatternException {
  if(preparedPattern == null) {
    throw new PatternException("A pattern is needed at " + SitemapParameters.getLocation(parameters));
  }
  RE re = new RE((REProgram)preparedPattern);
  String match = getMatchString(objectModel, parameters);
  if (match == null)
    return null;
  if(re.match(match)) {
    /* Handle parenthesised subexpressions. XXX: could be faster if we count
     * parens *outside* the generated code.
     * Note: *ONE* based, not zero, zero contains complete match
     */
    int parenCount = re.getParenCount();
    Map map = new HashMap();
    for (int paren = 0; paren <= parenCount; paren++) {
      map.put(Integer.toString(paren), re.getParen(paren));
    }
    return map;
  }
  return null;
}

代码示例来源:origin: org.apache.cocoon/cocoon-linkrewriter-impl

for (int i = 1; i < r.getParenCount(); i++) {
  link = r.getParen(i);
  newLink = createTransformedLink(link);

代码示例来源:origin: com.github.jkutner/saferegex

for (int i = 0; i < r.getParenCount(); i++)

相关文章