String inputLine = "Adams, John Quincy";
// Construct an RE with parens to "grab" both field1 and field2
RE r = new RE("(.*), (.*)");
if (!r.match(inputLine))
throw new IllegalArgumentException("Bad input");
System.out.println(r.getParen(2) + ' " + r.getParen(1));