diff --git a/src/gfn/marc/Lottozahlen.java b/src/gfn/marc/Lottozahlen.java index 8d82da8..c1f8f37 100644 --- a/src/gfn/marc/Lottozahlen.java +++ b/src/gfn/marc/Lottozahlen.java @@ -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?