// Uncolored, plain source file: trans.java
// trans.java by Steven R. Brandt
// <p>
// An example file explaining how to use
// com.stevesoft.pat, com.stevesoft.pat.wrap,
// and com.stevesoft.pat.apps
// <p>
// 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.*;
import java.io.*;
public class trans {
public static void main(String[] args) {
// It is sometimes the case that you wish to make
// many transformations on the same piece of text.
// This is made easier by the Transformer.
Transformer t = new Transformer(true);
t.add(new String[] {
"s/\\bspring\\b/summer/",
"s/\\bsummer\\b/fall/",
"s/\\bfall\\b/winter/",
"s/\\bwinter\\b/spring/"
});
// When this prints out, we find that the seasons have all
// been replaced so that summer is the first mentioned and
// sprint the last.
System.out.println(t.replaceAll("The seasons undergo changes: "
+"spring becomes summer, summer becomes fall, fall becomes "
+"winter, and winter becomes spring again."));
}
}