Get videoId of Vimeo with Regex - Javascript RegExp

Javascript examples for RegExp:RegExp Match

Description

Get videoId of Vimeo with Regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//  w  w  w  . j  a  v  a  2s. c  o m
var videoId ='http://vimeo.com/169473112';
var regExp = /vimeo.*(?:\/|clip_id=)([0-9a-z]*)/i;
var $body = document.querySelector('body');
var parsed = videoId.match(regExp) + '<br />';
$body.innerHTML += parsed;
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials