I think this way looks cleaner...
import java.util.regex.*;
Matcher matches = null;
if ((matches = Pattern.compile("^(\\d{1,2})[\\/.-](\\d{1,2})").matcher(input)).matches()) {
System.out.println("First Value: "+Integer.parseInt(matches.group(1)) );
System.out.println("Second Value: "+Integer.parseInt(matches.group(2))-1 );
}
|