Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would suggest an alternative regex, using sub-groups to capture name and value of the parameters individually:</p> <pre><code>function getUrlParams(url) { var re = /(?:\?|&amp;(?:amp;)?)([^=&amp;#]+)(?:=?([^&amp;#]*))/g, match, params = {}, decode = function (s) {return decodeURIComponent(s.replace(/\+/g, " "));}; if (typeof url == "undefined") url = document.location.href; while (match = re.exec(url)) { params[decode(match[1])] = decode(match[2]); } return params; } var result = getUrlParams("http://maps.google.de/maps?f=q&amp;source=s_q&amp;hl=de&amp;geocode=&amp;q=Frankfurt+am+Main&amp;sll=50.106047,8.679886&amp;sspn=0.370369,0.833588&amp;ie=UTF8&amp;ll=50.116616,8.680573&amp;spn=0.35972,0.833588&amp;z=11&amp;iwloc=addr"); </code></pre> <p><code>result</code> is an object:</p> <pre> { f: "q" geocode: "" hl: "de" ie: "UTF8" iwloc: "addr" ll: "50.116616,8.680573" q: "Frankfurt am Main" sll: "50.106047,8.679886" source: "s_q" spn: "0.35972,0.833588" sspn: "0.370369,0.833588" z: "11" } </pre> <p>The regex breaks down as follows:</p> <pre> (?: # non-capturing group \?|& # "?" or "&" (?:amp;)? # (allow "&amp;amp;", for wrongly HTML-encoded URLs) ) # end non-capturing group ( # group 1 [^=&#]+ # any character except "=", "&" or "#"; at least once ) # end group 1 - this will be the parameter's name (?: # non-capturing group =? # an "=", optional ( # group 2 [^&#]* # any character except "&" or "#"; any number of times ) # end group 2 - this will be the parameter's value ) # end non-capturing group </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload