Hi all I have a variable that is a YouTube url that is user-generated. There is a lot of threads on here about Regex and what not, but most are being executed in js. I want to run everything server-side in php, here is my simple function:
function youTubeID($url){
$url = preg_replace('http://youtu.be/ Regex goes here', '', $url);
return $url;
}
Markup:
<a href="http://youtu.be/yhXhVMKxnkY"><img src="http://img.youtube.com/vi/'.youTubeID($variable).'/0.jpg" /><img src="play.png" alt="Watch the video" title="Watch the video"/></a>
Question: Does anyone know the proper regex for http://youtu.be/ ?
I'm sure this is a quick answer, I'm not too savvy with regex. On a side note,does anyone know of any good resources where I can teach myself some good regex so I don't have to ask silly syntax questions like this? Cheers.