this is what I have so far:
[code=html]/(http://www.youtube.com/watch?v=[a-zA-Z0-9]+)/
which gets [url]http://www.youtube.com?v=abcABC123
but if the link is [url]http://www.youtube.com/watch?v=abcABC123&feature=related
this is the full code I am using it in:
[code=php]
function youtubeRender($uri) {
return “<a href=’$uri’>$uri</a>”;
}
function getYoutubeLink($string){
$regex = “/(http://www.youtube.com/watch?v=[a-zA-Z0-9]+)/”;
$string = preg_replace_callback($regex, create_function(‘$matches’, ‘return youtubeRender($matches[0]);’), $string);
return $string;
}
// this link work OK
echo getYoutubeLink(“http://www.youtube.com/watch?v=abcABC123 this video is cool”);
// this link doesn’t include “&feature=related” into the rendered link
echo getYoutubeLink(“http://www.youtube.com/watch?v=abcABC123&feature=related this video is cool”);
I haven’t really used Regular Expressions much, so If anyone with more knowledge than me can get it working, It would be much appreciated ?
Thanks