Last active
December 28, 2015 11:57
-
-
Save zhukovsergei/068e3335fc87686df90d to your computer and use it in GitHub Desktop.
Извлечение ID из YouTube ссылки
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function youTubeGetId(url) { | |
var expression = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be[.]?\/|youtube\.com[.]?\/(?:embed\/|v\/|watch\/?\?(?:\S+=\S*&)*v=))([\w-]{11})\S*$/; | |
return url.match(expression) ? RegExp.$1 : undefined; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment