// args.java //

// An example file distributed with com.stevesoft.pat // and com.stevesoft.pat.apps //

// This software comes without express or implied warranty. // No claim is made about the suitability of this software for // any purpose and neither I nor SteveSoft shall be liable for // damages suffered by the user of this software. import com.stevesoft.pat.*; // Deeply Weird Stuff: Giving // arguments to user defined patterns and // replacement rules. You probably don't // want to try and understand this unless // you are already defining and using your // own patterns and replacement rules. // This is a replace rule that copies the // matched text m times when replacing. // ${multi:3} is equivalent to $&$&$& // ${multi:5} is equivalent to $&$&$&$&$&. class MultiplicityRule extends ReplaceRule { int m = 1; MultiplicityRule() {} MultiplicityRule(int mi) { m = mi; } // This is the thing that does the actual replacing // see fancy.java for the basics. public void apply(StringBufferLike sb,RegRes rr) { for(int i=0;i/"); System.out.println(r.replaceAll("3 34 125")); // This should yield "3 <3434343434> 1<2525252525>" // Why? We only match on pairs of digits that add up // to 7. That means "34" and "25". They are replaced // with "<"+5 copies of the matched String+">" according // to our eccentric rules. } }