A regular expression to extract video ID and host name from a wide range of different youtube links. Built upon this foundation.
^(?:https?:\/\/)?(?:www\.)?(?:m\.)?((youtu\.be|youtube\.com)(?:\/embed\/watch\\?.+|\/watch\?v=|watch\?.+&v=|.))([\w-]{11})(?:.+)?$
- http://youtube.com/watch?v=iwGFalTRHDA
- http://www.youtube.com/watch?v=iwGFalTRHDA&feature=related
- https://youtube.com/iwGFalTRHDA
- http://youtu.be/n17B_uFF4cA
- youtube.com/iwGFalTRHDA
- youtube.com/n17B_uFF4cA
- http://www.youtube.com/embed/watch?feature=player_embedded&v=r5nB9u4jjy4
- http://www.youtube.com/embed/watch?v=r5nB9u4jjy4
- http://www.youtube.com/watch?v=t-ZRX8984sc
- http://youtu.be/t-ZRX8984sc