public static String parseUrl(String urlStr, String partToExtract, String key) {
		if (!"QUERY".equals(partToExtract)) {
			return null;
		}

		String query = parseUrl(urlStr, partToExtract);
		if (query == null) {
			return null;
		}

		Pattern p = Pattern.compile("(&|^)" + Pattern.quote(key) + "=([^&]*)");
		Matcher m = p.matcher(query);
		if (m.find()) {
			return m.group(2);
		}
		return null;
	}
public static String parseUrl ( String urlStr , String partToExtract , String key ) { if ( ! "QUERY" . equals ( partToExtract ) ) { return null ; } String query = parseUrl ( urlStr , partToExtract ) ; if ( query == null ) { return null ; } Pattern p = Pattern . compile ( "(&|^)" + Pattern . quote ( key ) + "=([^&]*)" ) ; Matcher m = p . matcher ( query ) ; if ( m . find ( ) ) { return m . group ( 2 ) ; } return null ; }
Parse url and return various parameter of the URL.
If accept any null arguments, return null.

@param urlStr        URL string.
@param partToExtract must be QUERY, or return null.
@param key           parameter name.
@return target value.