Posted By

mcarneiro on 04/23/10


Tagged

regexp


Versions (?)

get queryString param


 / Published in: JavaScript
 

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

  1. // usage: getQueryValue("http://localhost-vm/site/default.aspx?123deds=122223&winner=carneiro0&deds=123", "deds") // returns 123
  2.  
  3. var getQueryValue = function(p_str, p_param){
  4. return (p_str ? p_str.match(new RegExp('(?:\\?|&|&)'+p_param+'=(.*?)(?:&|$)')) : [])[1];
  5. };

Report this snippet  

You need to login to post a comment.