I have this url
http://host.com/routingRequest?returnJSON=true&timeout=60000&to=s%3A73746647+d%3Afalse+f%3A-1.0+x%3A-74.454383+y%3A40.843021+r%3A-1.0+cd%3A-1.0+fn%3A-1+tn%3A-1+bd%3Atrue+st%3ACampus%7EDr&returnGeometries=true&nPaths=1&returnClientIds=true&returnInstructions=true
&hour=12+00&from=s%3A-1+d%3Afalse+f%3A-1.0+x%3A-74.241765+y%3A40.830182+r%3A-1.0+cd%3A-1.0+fn%3A56481485+tn%3A26459042+bd%3Afalse+st%3AClaremont%7EAve&sameResultType=true&type=HISTORIC_TIME
and i try to fetch
to = -74.454383, 40.843021
from = -74.241765, 40.830182
hour = 12+00
with this code:
String patternString = "(x%3A) (.+?) (y%3A) (.+?) (r%3A)";
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher(freshResponse.regression_requestUrl);
H4 h4 = new H4().appendText("Response ID: " + id);
Ul ul = new Ul();
Li li1 = new Li();
Li li2 = new Li();
if (matcher.find()) {
li1.appendText("From: " + matcher.group(1) + ", " + matcher.group(2));
}
if (matcher.find()) {
li2.appendText("To: " + matcher.group(1) + ", " + matcher.group(2));
}
patternString = "(&hour=) (.+?) (&from=)";
pattern = Pattern.compile(patternString);
matcher = pattern.matcher(freshResponse.regression_requestUrl);
Li li3 = new Li();
if (matcher.find()) {
li3.appendText("At: " + matcher.group(1));
}
but i get no matches. what am i missing?
could I have done this without regex more easily?
URIinstead, and.getQuery(); it will be much easier to extract what you want afterwards