public int stringToInt(String str) { // deleting everything that is not numeric return Integer.parseInt(str.replaceAll("[^0-9.]","")); }