Pattern pattern = null;
try {
pattern = Pattern.compile (argv [0]);
} catch (PatternSyntaxException e) {
System.out.println ("The regular expression '"
+ argv [0] + "' contains a "
+ "syntax error: " + e.getMessage());
}
String [] tokens = pattern.split (argv [1]);
for (int i = 0; i < tokens.length; i++) {
System.out.println ("" + i + ": " + tokens [i]);
}