preg_match and preg_replace for youtube url
<p>i have this code </p>

<pre><code>preg_match_all('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&amp;]v=)|youtu\.be/)([^"&amp;?/ ]{11})%i', $asd, $match);
</code></pre>

<p>to find youtube key of urls like </p>

<pre><code>&lt;a href="http://www.youtube.com/watch?v="&gt;http://www.youtube.com/watch?v=ZiJRPREeQ1Q&lt;/a&gt;
         &lt;br /&gt;
         &lt;a href="http://www.youtube.com/watch?v=GaEZgqxPHLs&amp;feature=related"&gt;http://www.youtube.com/watch?v=GaEZgqxPHLs&amp;feature=related&lt;/a&gt;
</code></pre>

<p>this work good to find the code ZiJRPREeQ1Q and GaEZgqxPHLs , now i want to replace all the html line with a new code </p>

<p>wanna to use </p>

<pre><code>preg_replace
</code></pre>

<p>to find the whole youtube url </p>

<pre><code>&lt;a href="*"&gt;*&lt;/a&gt; 
</code></pre>

<p>to a new code  how can i do that ?</p>

<p>--------------adds--------------</p>

<p>after i get the code of youtube from url by preg_math_all
i used this code to extract the codes </p>

<pre><code>foreach($match[1] as $youtube){
           // $youtube; // this handle the youtube code
           $match = "";  // what can i write here relative to $youtube ?
          $str .= preg_replace($match, 'new code',$content); // $content handle the whole thread that contain the youtube url &lt;a href=*&gt;*&lt;/a&gt;                                  
         }
</code></pre>

<p>the only thing that i need that what's regular expression that i can use to replace youtube code </p>
