I have this preg_match rule that transforms plain youtube link into an actual player html code:
preg_match('#(?:http://)?(?:www\.)?(?:youtube\.com/(?:v/|watch\?)|youtu\.be/)([\w-]+)(?:\S+)?#', $text, $youtube_match);
1) It doesn’t work if I have a tag right after the video link, let’s say a br tag: http://www.youtube.com/watch?v=4rUGhlNCNho<br /> , it probably thinks that the <br is part of the URL.
2) How should I modify the rule to match also a mixed order of the url variable, e.g:
http://www.youtube.com/watch?feature=player_embedded&v=4rUGhlNCNho
instead of
http://www.youtube.com/watch?v=4rUGhlNCNho
If iam right, you only need the parameter v= to generate and embed video