[Solved] Splitting a String which has longitude and latitude points


If we can guarantee that the String to parse is always defined in a canonical way, so that is defined as lat+long ALWAYS, then using regex will be the easiest way:

Example:

 String latLong = "lat/lng: (55.94569390835889,-3.190410055779333)";
 Pattern patte = Pattern.compile("-?[0-9]+(?:.[0-9]+)?");
 Matcher matcher = patte.matcher(latLong);
 while (matcher.find()) {
      System.out.println(Double.parseDouble(matcher.group()));
 }

solved Splitting a String which has longitude and latitude points