Created
January 18, 2013 02:13
-
-
Save RhinoLu/4561786 to your computer and use it in GitHub Desktop.
Get YouTube Video ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| http://gskinner.com/RegExr/?2tsac | |
| Author: Roberto Rama | |
| */ | |
| var pattern:RegExp = /(?<=v(\=|\/))([-a-zA-Z0-9_]+)|(?<=youtu\.be\/)([-a-zA-Z0-9_]+)/gm; | |
| var result:Object = pattern.exec("http://www.youtube.com/watch?v=9bZkp7q19f0"); | |
| trace(result); | |
| /* | |
| www.youtube.com/v/VIDEOID | |
| www.youtube.com?v=VIDEOID | |
| www.youtube.com/watch?v=VIDEOID | |
| youtu.be/VIDEOID | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment