Browse Source

Trying regex split

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

4
ParseString.java

@ -4,8 +4,8 @@ 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]);

Loading…
Cancel
Save