i have to extract a string between /
and ?
, i.e exampleproduct
https://local.host.com/order/faces/Home/myorder/exampleproduct?_adf.ctrl-state=mfun9p14r_19
how to write regular expression for this i am using this logic but i am unable to
private static String extractPageNameFromURL(String urlFull) {
if (urlFull != null) {
Pattern pattern = Pattern.compile("/(.*?).jspx?");
Matcher matcher = pattern.matcher(urlFull);
while (matcher.find()) {
String str1 = matcher.group(1);
String[] dataRows = str1.split("/");
urlFull = dataRows[dataRows.length - 1];
}
}
return urlFull;
}
public static void main(String[] args) {
System.out.println(DtmUtils.extractPageNameFromURL("https://local.host.com/order/faces/Home/myorder/exampleproduct?_adf.ctrl-state=mfun9p14r_19"));
}
Thanks Raj