private int costPatternWithWildCardChar(Stack<Node> stack) throws SemanticException {
    int numElems = (stack != null ? stack.size() : 0);
    StringBuilder name = new StringBuilder();
    Matcher m = patternWithWildCardChar.matcher("");
    for (int pos = numElems - 1; pos >= 0; pos--) {
      String nodeName = stack.get(pos).getName() + "%";
      name.insert(0, nodeName);
      m.reset(name);
      if (m.matches()) {
        return name.length();
      }
    }
    return -1;
  }
This function returns the cost of the rule for the specified stack when the pattern
matched for has wildcard character in it. The function expects patternWithWildCardChar
to be not null.

@param stack
         Node stack encountered so far
@return cost of the function
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/lib/RuleRegExp.java