Get the ID of a YouTube link from Matlab

4 次查看(过去 30 天)
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.

采纳的回答

KSSV
KSSV 2016-5-23
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 ?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by