I've been trying to extract part of a string. I'm doing it in an Android App (Java).
My problem is that I'll have a string that starts out like this:
Location[fused 20.01234,-30.9876 acc=20 (...)
That represents the device's current coordinates (I made up 20 and -30 there) and some other measurements. I want to extract the 2 coordinates from that string (they'll always be in between "fused " and " acc"), and store them as floats.
I've looked around and concluded that probably RegExs are needed to solve this, but keep in mind I've only used Regular Expressions once before, and I'm still very inexperienced with them.
Any guidance on how to go about solving this will be greatly appreciated!
String location = "Location[fused 20.01234,-30.9876 acc=20"; location = location.substring(location.indexOf(" "), location.lastIndexOf(" ")); String locationArr[]= location.split(","); System.out.println("lat : "+locationArr[0]); System.out.println("long: " + locationArr[1]);