Here is an example of what this does:
String result = new Rewriter("([0-9]+) US cents") {
public String replacement() {
long dollars = Long.parseLong(group(1))/100;
return "$" + dollars;
}
}.rewrite("5000 US cents");
System.out.println(result);
prints>> $50
nice!
No comments:
Post a Comment