title: Using preg_match to filter youtube URLS in php
body: <p>I am using the following code to convert youtube URLS in my posts to embedded videos. But this is not working if I add the URL with https:// and youtu.be format. How should I fix it?</p>
  
  <pre><code>  $youtube_url = "/http:\/\/www\.youtube\.com\/watch\?(.*?)v=([a-zA-Z0-9_\-]+)(\S*)/i";
    if (preg_match($youtube_url, $text, $youtube)){
     // echo "match found";
    }
  </code></pre>