Get the ID of a YouTube link from Matlab

1 visualizzazione (ultimi 30 giorni)
Hello, I wanted to ask if there is any way to get the ID of a Youtube URL from Matlab or how I could do it , that is, if I have the following URL for example :
https://www.youtube.com/watch?v=e4d0LOuP4Uw
Remove or get : e4d0LOuP4Uw
Or on the other hand , I have seen a php function that you can do but how I could call or do the same in Matlab ?
id_youtube function ( $ url ) { $ patron = ' % ^ (?: https : // ) ? ( : Www \ . ) ? ( : Youtu \ .be / | youtube \ .com ( : / embed / | / v / | / watch \ v = ) ? ) ( [ \ W -] { 10,12 } ) $ % x ' ; $ Array = preg_match ( $ patron , $ url , $ parte ) ; if ( false ! == $ array) { return $ parte [ 1]; } return false; }
Echo id_youtube ( ' https://www.youtube.com/watch?v=9WZn9PkTDJY '); // Prints : 9WZn9PkTDJY
Thanks in advanced.

Risposta accettata

KSSV
KSSV il 23 Mag 2016
link = 'https://www.youtube.com/watch?v=e4d0LOuP4Uw' ; % youtube link
pos = strfind(link,'=') ; % GEt the position of =
id = link(pos+1:end) ; % Get the part after =
As the id is appearing after '=', cant you get the position of '=' and take the string after ?

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by