Extract parameter value from url using regular expressions

后端 未结 6 1674
抹茶落季
抹茶落季 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:54

    v is a query parameter, technically you need to consider cases ala: http://www.youtube.com/watch?p=DB852818BF378DAC&v=1q-k-uN73Gk

    In .NET I would recommend to use System.Web.HttpUtility.ParseQueryString

    HttpUtility.ParseQueryString(url)["v"];
    

    And you don't even need to check the key, as it will return null if the key is not in the collection.

提交回复
热议问题