I have a String that has data such as:
String data = "Some information and then value1=17561.2 and then value2=15672.2"
How do I return 17561.2 most efficiently in Java?
String queryString = "value1";
while data.charAt(outputStr.indexOf(queryString)+queryString.length()) is a number
-save it to an array
which you later convert to a String
elihw
This seems kind-of convoluted.
Would regexs be perfect here? How would I craft a regular expression to do this?
To find a decimal number (or an int) in a string, you could use the regular expression
This will not find floats in exponential notation, though (1.2E15 or some such).
Explanation:
In Java (to iterate over all matches in a string):