Browse Source

Trying regex split

master
Raphael Roberts 7 years ago
parent
commit
88676eab65
  1. 6
      ParseString.java

6
ParseString.java

@ -4,12 +4,12 @@ public class ParseString{
this.str = str;
}
public double sumOfAll(){
String new_str = this.str.replaceAll(" +",",");
String[] parts = new_str.split(",");
//String new_str = this.str.replaceAll(" +",",");
String[] parts = this.str.split(",| +");
double total = 0;
for (int i = 0; i < parts.length; i ++){
total += Double.parseDouble(parts[i]);
}
return total;
}
}
}
Loading…
Cancel
Save