Blogs, online journals and in general the 90% of the content management system, use XHTML output as markup language. Both strict and transitional version.
Often people choose to embed youtube videos in their websiste. To avoid the annoing cut & paste of the embed code given by youtube, I choose to code a simple script to replace a proprierty tag, whit the embed code.

This little piece of code, allow me to write a simple line, containing the pseudo tag youtube and a video's permalink inside and show the embeded video without copy and paste the relative code.
In the first versione of the script I just used the youtube embed code model. But the code generated using the original youtube code, is NOT HTML valid. So I decide to rewrite it more carefull, and make it XHTML valid.
Using PHP, the result is a simple mono-line script.
$result = preg_replace('#\[youtube\]http://www.youtube.com/watch\?v=(.*?)\[/youtube\]#i', '<object type="application/x-shockwave-flash" style="width:450px; height:366px;" data="http://www.youtube.com/v/\\1"><param name="movie" value="http://www.youtube.com/v/\\1" /><param name="wmode" value="transparent" /></object>',$testo)
Where $testo is the pattern to check.









