Javascript regular expression for extracting Youtube video ids

后端 未结 4 1406
清酒与你
清酒与你 2021-01-15 05:35

The following code is used to get Youtube video ids in order to get a thumbnail image.

What is the reasoning behind the first regular expression and what is it doing

4条回答
  •  误落风尘
    2021-01-15 06:22

    If you are referring to...

    results = url.match("[\\?&]v=([^&#]*)");
    

    Then it is matching a literal \, ? or & followed by literal v= followed by a capturing group which is capturing 0 or more of any characters that are not & or #.

提交回复
热议问题