Friday, 6 January 2017

javascript - Getting all URL parameters using regex











Trying to get a regex (Javascript).



Input:   url.html?id=14114&yolo=hahaha
Output: id=14114
yolo=hahaha



So this is what i have done so far: (\&|\?)(.*?)\=(.*?)



How do I also include the red circled regions?



enter image description here


Answer



How about this pattern:



(\?|\&)([^=]+)\=([^&]+)


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...