Last active
December 18, 2015 05:39
-
-
Save sivaprabug/5733982 to your computer and use it in GitHub Desktop.
Separate the YouTube video link from a given paragraph...
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 | |
$message= 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit http://www.youtube.com/watch?v=LSoXrR2Xec4 Lorem ipsum dolor sit amet, consectetuer adipiscing elit http://www.youtube.com/watch?v=0SARbwvhupQ '; | |
$regex = '/\b[http|https]?\:\/\/\w+\.youtube\.com\/watch\?v\=(\w+)\b/'; | |
$matches = array(); | |
preg_match_all($regex, $message, $matches); | |
print_r($matches[1]); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All credit goes to https://www.facebook.com/chatterjeeHirak