Logo Search packages:      
Sourcecode: jmk version File versions  Download package

static StringList edu::neu::ccs::jmk::StringUtils::patsubst ( String  pattern,
String  replacement,
StringList  input,
StringList  list 
) [inline, static, package]

The patsubst function matches the pattern with the strings in the input. A string that does not match is copied unchanged to the output. A string that does match is replaced by a string generated by replacing wild cards in the replacement with the match. When the replacement does not contain a wild card, the match is concatenated with the replacement.

See also:

Definition at line 82 of file StringUtils.java.

References edu::neu::ccs::jmk::StringList::getRest(), edu::neu::ccs::jmk::StringList::getString(), edu::neu::ccs::jmk::Matcher::match(), and edu::neu::ccs::jmk::StringList::setRest().

    if (input == null)
      return list;
    else {
      StringList head = new StringList("");
      StringList last = head;
      Matcher matcher = new Matcher(pattern);
      for (; input != null; input = input.getRest()) {
      String string = input.getString();
      String match = matcher.match(string);
      if (match != null) {
        if (Matcher.isPattern(replacement))
          string = Matcher.subst(match, replacement);
          string = match + replacement;
      StringList temp = new StringList(string);
      last = temp;
      return head.getRest();

Generated by  Doxygen 1.6.0   Back to index