var subject = "https://vimeo.com/195940605"; var result = subject.match(/(?:www.|player.)?vimeo.com/(?:channels/(?:w+/)?|groups/(?:[^/]*)/videos/|album/(?:d+)/video/|video/|)(d+)(?:[a-zA-Z0-9_-]+)?/i); document.write(result[0]);