2 // This software is now distributed according to
\r
3 // the Lesser Gnu Public License. Please see
\r
4 // http://www.gnu.org/copyleft/lesser.txt for
\r
6 // -- Happy Computing!
\r
8 package com.stevesoft.pat;
\r
11 * This method implements the pattern elements $1, $2, etc in a substitution
\r
12 * rule. The apply(StringBufferLike sb,RegRes rr) method of this ReplaceRule
\r
13 * simply appends the contents of rr.stringMatched(n), where n is the integer
\r
14 * supplied to the constructor.
\r
16 public class BackRefRule extends ReplaceRule
\r
20 public BackRefRule(int n)
\r
25 public void apply(StringBufferLike sb, RegRes res)
\r
27 String x = res.stringMatched(n);
\r
28 sb.appendStr(x == null ? "" : x);
\r
31 public String toString1()
\r
36 public Object clone1()
\r
38 return new BackRefRule(n);
\r