+1  A: 

This matches the video id in a youtube url.

[\\?&]v= // finds the first ?v= or &v= in the query string

([^&#]*) // matches everything else up to the next & or #

The video id is stored in results[1] (assuming there was a match)

Rob
+10  A: 

It's using a regular expression to extract the ID of the video from a complete URL. This particular regex breaks down as follows:

  1. [\\?&] is a character class. It matches a single character which is either & or ?. (The question mark is a special character in JavaScript regexes, so it must be escaped by preceding it with a backslash. The backslash is a special character in JavaScript strings, so it must be escaped also, hence the double backslash. That's fairly common in regular expressions.)
  2. v= matches the literal string v=.
  3. ( begins a capturing group, so everything until the next ) will be placed into a separate entry in the returned array.
  4. [^&#]* any number of characters (including none) until a & or # is found. The brackets indicate a character class as above, and the ^ inverts the class so it includes all characters except those listed before the end bracket. The * indicates that the preceding character class is to be matched zero or more times.
  5. The ) ends the capturing group.

Assuming the match is successful, results[0] contains the entire URL, and results[1] contains the contents of the first capturing group, i.e. the ID of the video.

bcat
+1 for explaining step-by-step; it's the most helpful answer posted
Andreas Grech
+1 I agree with Andreas Grech
a432511
Deleted my post. Yours is better :-)
a432511
That wasn't necessary; there's plenty of room here for both of us. :D Still, thanks for the compliment. I'm glad people think my explanation is helpful.
bcat