It looks like you're using an Ad Blocker.

Please white-list or disable AboveTopSecret.com in your ad-blocking tool.

Thank you.

 

Some features of ATS will be disabled while you continue to use an ad-blocker.

 

YouTube video ID extractor (in JavaScript regex)

page: 1
5

log in

join
share:

posted on Mar, 1 2007 @ 07:04 PM
link   
I thought I'd let you all know that I created a JavaScript YouTube video ID extractor. It uses the built in regular expressions to get it.

You can see a proof of concept here.

The relevant function is below:

function youtubeIDextract(url)
[
var youtube_id;
youtube_id = url.replace(/^[^v]+v.(.[11]).*/,"$1");
return youtube_id;
]

I figured you'd want to incorporate this into ATS.


Note that it works with all of the following YouTube URLs:
youtube.com...
www.youtube.com...
youtube.com...

Also, if an ID is already there, it doesn't get mangled.

Please test it to see if there are any corner cases I might have missed.

I'm going to work on something similar for Google Video. I'll start another thread here once I'm finished.



posted on Mar, 1 2007 @ 07:42 PM
link   
Thanks. This will make embedding videos much easier.

Appreciate what you've done.



posted on Mar, 3 2007 @ 02:43 AM
link   

Originally posted by DJMessiah
Thanks. This will make embedding videos much easier.

Appreciate what you've done.
Thanks for the complement. Much appreciated.



posted on Mar, 3 2007 @ 03:10 AM
link   
good job !
Scripts and other work gets very unappreciated, just wanted to say that.




top topics
 
5

log in

join