forked from hummel/PR1-Spreadsheet
Regex für fehlerhafte eingaben
parent
baa6d8a092
commit
f10415dec8
|
@ -18,6 +18,7 @@ public class Axel {
|
||||||
spr.put("A3", "123");
|
spr.put("A3", "123");
|
||||||
|
|
||||||
spr.put("B9", "=41+A2+10-2/3");
|
spr.put("B9", "=41+A2+10-2/3");
|
||||||
|
spr.put("B9", "2");
|
||||||
|
|
||||||
System.out.println("Schreibe 'stop' zum anhalten.");
|
System.out.println("Schreibe 'stop' zum anhalten.");
|
||||||
do{
|
do{
|
||||||
|
@ -28,26 +29,27 @@ public class Axel {
|
||||||
System.out.println(spr);
|
System.out.println(spr);
|
||||||
System.out.println("Befehl (z.B. D4_=7*6): ");
|
System.out.println("Befehl (z.B. D4_=7*6): ");
|
||||||
command = input.nextLine();
|
command = input.nextLine();
|
||||||
if(command.contentEquals("stop"))
|
if(command.matches("[A-Za-z][1-9][0-9]?_=((([A-Za-z][1-9][0-9]?)|([0-9]+))(\\*|\\+|\\-|\\/))*(([A-Za-z][1-9][0-9]?)|([0-9]+))")) {
|
||||||
break;
|
for(int i = 0; i<command.length();i++) {
|
||||||
for(int i = 0; i<command.length();i++) {
|
if(command.charAt(i)=='_') {
|
||||||
if(command.charAt(i)=='_') {
|
cellTRUE = false;
|
||||||
cellTRUE = false;
|
continue;
|
||||||
continue;
|
}
|
||||||
|
if(cellTRUE) {
|
||||||
|
cell+=command.charAt(i);
|
||||||
|
}else {
|
||||||
|
form+=command.charAt(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(cellTRUE) {
|
spr.put(cell, form);
|
||||||
cell+=command.charAt(i);
|
}else if(command.matches("stop")){
|
||||||
}else {
|
break;
|
||||||
form+=command.charAt(i);
|
}else {
|
||||||
}
|
System.out.println("Die Eingabe war nicht korrekt. Die Tabelle bleibt auf folgendem stand:");
|
||||||
}
|
}
|
||||||
spr.put(cell, form);
|
|
||||||
|
|
||||||
}while(true);
|
}while(true);
|
||||||
|
|
||||||
spr.saveCsv("tmp/test.csv");
|
spr.saveCsv("tmp/test.csv");
|
||||||
|
|
||||||
// TODO: You might want to put "UI loop" for entering value and formulas here resp. in some UI methods.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue