Get the ID of a YouTube link from Matlab

1 Ansicht (letzte 30 Tage)
Mario Martos
Mario Martos am 23 Mai 2016
Kommentiert: Mario Martos am 24 Mai 2016
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.

Akzeptierte Antwort

KSSV
KSSV am 23 Mai 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 ?

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by