--- /dev/null
+//\r
+// This software is now distributed according to\r
+// the Lesser Gnu Public License. Please see\r
+// http://www.gnu.org/copyleft/lesser.txt for\r
+// the details.\r
+// -- Happy Computing!\r
+//\r
+package com.stevesoft.pat;\r
+\r
+/** This method implements the pattern elements $1, $2, etc in\r
+ a substitution rule. The apply(StringBufferLike sb,RegRes rr) method of this ReplaceRule\r
+ simply appends the contents of rr.stringMatched(n), where n is\r
+ the integer supplied to the constructor. */\r
+public class BackRefRule extends ReplaceRule {\r
+ int n;\r
+ public BackRefRule(int n) { this.n = n; }\r
+ public void apply(StringBufferLike sb,RegRes res) {\r
+ String x = res.stringMatched(n);\r
+ sb.append(x == null ? "" : x);\r
+ }\r
+ public String toString1() { return "$"+n; }\r
+ public Object clone1() { return new BackRefRule(n); }\r
+}\r