I\'m asking the user for input through the Scanner
in Java, and now I want to parse out their selections using a regular expression. In essence, I show them an enu
To "parse out" the integers, you don't necessarily want to match the input, but rather you want to split it on spaces (which uses regex):
String[] nums = input.trim().split("\\s+");
If you actually want int
values:
List selections = new ArrayList<>();
for (String num : input.trim().split("\\s+"))
selections.add(Integer.parseInt(num));