从url中提取参数:
public static String getUrlparameter(String url, String name) {
url += "&";
String pattern = "(\\?|&){1}#{0,1}" + name + "=[a-zA-Z0-9]*(&{1})";
Pattern r = Pattern.compile(pattern);
Matcher matcher = r.matcher(url);
if (matcher.find()) {
return matcher.group(0).split("=")[1].replace("&", "");
} else {
return null;
}
}
使用方法:
Log.d(TAG," a === >>" + StringUtils.getUrl(result,"a"));
Log.d(TAG," p === >>" + StringUtils.getUrl(result,"p"));
Log.d(TAG," c === >>" + StringUtils.getUrl(result,"c"));