Extract parameter value from url using regular expressions

后端 未结 6 1644
抹茶落季
抹茶落季 2020-12-08 06:19

This should be very simple (when you know the answer). From this question

I want to give the posted solution a try. My question is:

How to get the parameter

6条回答
  •  囚心锁ツ
    2020-12-08 06:56

    Why dont you take the string and split it

    Example on the url

    var url = "http://www.youtube.com/watch?p=DB852818BF378DAC&v=1q-k-uN73Gk"
    

    you can do a split as

    var params = url.split("?")[1].split("&");
    

    You will get array of strings with params as name value pairs with "=" as the delimiter.

提交回复
热议问题