Return to Snippet

Revision: 26341
at April 23, 2010 15:57 by mcarneiro


Updated Code
// usage: getQueryValue("http://localhost-vm/site/default.aspx?123deds=122223&winner=carneiro0&deds=123", "deds") // returns 123

var getQueryValue = function(p_str, p_param){
	return (p_str ? p_str.match(new RegExp('(?:\\?|&|&)'+p_param+'=(.*?)(?:&|$)')) : [])[1];
};

Revision: 26340
at April 23, 2010 10:32 by mcarneiro


Initial Code
// usage: getQueryValue("http://localhost-vm/site/default.aspx?123deds=122223&winner=carneiro0&deds=123", "deds") // returns 123

var getQueryValue = function(p_str, p_param){
	var matched = p_str ? p_str.match(new RegExp('(?:\\?|&|&)'+p_param+'=(.*?)(?:&|$)')) : [];
	return matched[1];
};

Initial URL

                                

Initial Description
simple function to get querystring from a custom address using regular expression

Initial Title
get queryString param

Initial Tags
regexp

Initial Language
JavaScript