Sunday, June 16, 2019

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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...