Leerzeichen erlauben

This commit is contained in:
Marc Koch 2020-04-09 10:12:40 +02:00
parent 77f4a7ba2b
commit 8bae4ff05a
1 changed files with 2 additions and 2 deletions

View File

@ -15,12 +15,12 @@ public class Lottozahlen {
System.out.println("Bitte geben Sie sechs, mit Kommata getrennte, Lottozahlen (1 - 49) ein. " +
"(Beispiel: \"6,12,29,34,40,46\")");
String eingabe = scanner.next();
if (eingabe.matches("([1-4][0-9][,]|[0-9][,]){5}[1-4][0-9]|[0-9]")) {
if (eingabe.matches("([\\s]*[1-4][0-9][\\s]*[,][\\s]*|[\\s]*[0-9][\\s]*[,][\\s]*){5}[1-4][0-9][\\s]*|[0-9][\\s]*")) {
String[] zahlen = eingabe.split("[,]");
for (String zahl : zahlen) {
lottoschein.add(Integer.parseInt(zahl));
lottoschein.add(Integer.parseInt(zahl.trim()));
}
// Prüfung: Doppelte Zahlen?