title: Regex to match Youtube URL's
body: <p>I am trying to validate a Youtube URL using regex:</p>
  
  <pre><code>preg_match('~http://youtube.com/watch\?v=[a-zA-Z0-9-]+~', $videoLink)
  </code></pre>
  
  <p>It kind of works, but it can match URL's that are malformed. For example, this will match ok:</p>
  
  <pre><code>http://www.youtube.com/watch?v=Zu4WXiPRek
  </code></pre>
  
  <p>But so will this:</p>
  
  <pre><code>http://www.youtube.com/watch?v=Zu4WX£&amp;P!ek
  </code></pre>
  
  <p>And this wont:</p>
  
  <pre><code>http://www.youtube.com/watch?v=!Zu4WX£&amp;P4ek
  </code></pre>
  
  <p>I think it's because of the <code>+</code> operator. It's matching what seems to be the first character after <code>v=</code>, when it needs to try and match everything behind <code>v=</code> with <code>[a-zA-Z0-9-]</code>. Any help is appreciated, thanks.</p>