DEV Community

Cover image for Easy way to get parameters from a URL

Easy way to get parameters from a URL

Maher Alkendi on July 26, 2019

Getting Url parameters can be tricky. I am sure I am not the only one that has used google to search for the perfect regular expression to help ext...
Collapse
 
jsn1nj4 profile image
Elliot Derhay

Nice! Didn't know about that.

Previously I would split the url at the ? and then split the second array element (the string containing the query string) at each & (if it existed) and then split each new array element at the = to get the parameter list.

Of course I also found that on Stack Overflow a while ago. I definitely didn't invent that one.

Collapse
 
ma7eer profile image
Maher Alkendi

Ya I used to do the same thing until I fell on this trick from... Stack Overflow haha

From there I went to MDN to understand the API more. Hopefully it gets support from IE at some point