I am trying to save the bolded text to a string.
I have come up with the regex "routeName?.+?routeLengthKM" and according to an online regex tester this should get me what I want with the find method but it is only returning true/false. How can i save the bolded text to a string?
"routes:[{routeName:Dulles Toll Rd W; SR-28 S,routeDurationInMinutes:18,routeLengthKM:21.474,routeLengthMiles:13.343320854,toll:true},{routeName:Frying Pan Rd; SR-28 S,routeDurationInMinutes:18,routeLengthKM:19.437,routeLengthMiles:12.077588127,toll:false}
package regex;
import java.util.regex.*;
public class regexclass {
public static void main (String args[]){
Pattern p= Pattern.compile("routeName?.+?routeLengthKM");
Matcher m= p.matcher("routes:[{routeName:Dulles Toll Rd W; SR-28 S,routeDurationInMinutes:18,routeLengthKM:21.474,routeLengthMiles:13.343320854,toll:true},{routeName:Frying Pan Rd; SR-28 S,routeDurationInMinutes:18,routeLengthKM:19.437,routeLengthMiles:12.077588127,toll:false}]");
System.out.println(m.find());
}
}