The delimiter is a comma or 0 or more space characters ('\ s'). The value * means "0 or more." Scanner found "0 or more" whitespace between - and 1 , so it separates these characters, which ultimately eliminates the input mismatch.
You want to have 1 or more whitespace as a delimiter, so change the * value to + to reflect this intention.
input.useDelimiter(",|\\s+");
When making this change, I get the expected result:
1 -1
rgettman
source share