Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

JavaScript GetVars Array (See related posts)

Figure out which Get-Vars are defined using client side javascript regex:

   1  
   2  function getvars(s){
   3  // php preg_match would be as easy as: (/([^&?=])=[^&?=]/g)
   4    a = s.match(/[^&?=]*=[^&?=]*/g);
   5    r = new Array();
   6    for (i=0; i<a.length; i++) {
   7    	r[i] = a[i].match(/[^&?=]*/)[0];
   8    }
   9    return(r);
  10  }
  11  /* test */
  12  alert(getvars(window.location.search));

You need to create an account or log in to post comments to this site.


Click here to browse all 5545 code snippets

Related Posts