title: Regular expression to parse YouTube embedded code
body: <p>How can I take the YouTube embedded code that YouTube provides and use a regular expression to convert it to valid FBML code, that is, use the <code>fb:swf</code> tag?</p>
  
  <p>So far the regular expression I've come up with is:</p>
  
  <pre><code>preg_replace('/&lt;object(.*)&lt;\/object&gt;/i', "Whatever I need here...", $str);
  </code></pre>
  
  <p>I know it's lame, but it's my first try.</p>
  
  <p>PS: Sample of the YouTube embedded code,</p>
  
  <pre><code>&lt;object width="640" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/NWHfY_lvKIQ&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/NWHfY_lvKIQ&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;
  </code></pre>