Skip to content

Instantly share code, notes, and snippets.

@victorkurauchi
Created May 22, 2014 17:36
Show Gist options
  • Save victorkurauchi/9863ff17d53e35ad8f81 to your computer and use it in GitHub Desktop.
Save victorkurauchi/9863ff17d53e35ad8f81 to your computer and use it in GitHub Desktop.
var str = 'https://www.youtube.com/watch?v=iG6yKgnTrgo';
var youtubeId = str.indexOf('v=');
var limit = str.indexOf('&')
if (limit < 0) {
var stringYoutube = str.slice(youtubeId + 2);
} else {
var stringYoutube = str.slice(youtubeId + 2, limit);
}
alert(stringYoutube);
@victorkurauchi
Copy link
Author

var str = '';
var imgFormat = str.indexOf('.');
var format = str.slice(imgFormat);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment