HackerWins/summernote — pull request #664 by littlebigbot (2014-10-16 20:27:15+00:00)
Title: Improved Youtube Regex

The current youtube regex matches vine videos and inserts them as youtube embeds.

```javascript
// Current regex:
var ytRegExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
'https://vine.co/v/MYLuZlYrrOX'.match(ytRegExp); // ["https://vine.co/v/MYLuZlYrrOX", "v/", "MYLuZlYrrOX"]
```

```javascript
// New regex:
var ytRegExp = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/
'https://vine.co/v/MYLuZlYrrOX'.match(ytRegExp); // null
'http://youtu.be/DydIK14AvXI'.match(ytRegExp); // ["http://youtu.be/DydIK14AvXI", "DydIK14AvXI", "I"]
'https://www.youtube.com/watch?v=DydIK14AvXI'.match(ytRegExp) // ["https://www.youtube.com/watch?v=DydIK14AvXI", "DydIK14AvXI", "I"]
'www.youtube.com/embed/DydIK14AvXI'.match(ytRegExp) // ["www.youtube.com/embed/DydIK14AvXI", "DydIK14AvXI", "I"]
```