title: Get YouTube video id from thumbnail using regex in javascript?
body: <p>the Javascript below only works as for youtube videos actual url.</p>
  
  <pre><code>&lt;script&gt;
  regex = /http\:\/\/www\.youtube\.com\/watch\?v=(\w{11})/;
  url = 'http://www.youtube.com/watch?v=VK4ah66jBvE&amp;feature=feedu';
  id = url.match(regex)[1];
  document.write(''+id+'');
  &lt;/script&gt;
  </code></pre>
  
  <p>what i dont know how to do is a regex if the url happened to be a thumbnail of a youtube video which in this example would be <code>http://i1.ytimg.com/vi/VK4ah66jBvE/0.jpg</code> ? I have tried</p>
  
  <pre><code>&lt;script&gt;
  regex = /http\:\/\/i1\.ytimg\.com\/vi(\w{11})/0.jpg;;
  url = 'http://i1.ytimg.com/vi/VK4ah66jBvE/0.jpg';
  id = url.match(regex)[1];
  document.write(''+id+'');
  &lt;/script&gt;
  </code></pre>