I am working on a macro for responsive youtube video to use in the grid editor. The idea is that the editor enters the url and the macro does the rest. To get it to work I need to strip the url down to only contain everything after the = in youtube url's. From this: https://www.youtube.com/watch?v=erLk59H86ww To this: erLk59H86ww
I thought I could do something like this:
@if (Model.MacroParameters["ytVideoLink"] != null) { var fullLink = Model.MacroParameters["ytVideoLink"]; var videoId = fullLink.Split('=').Last();
Thank you very much for pointing me in the right direction :) I worked out a solution based on the link you provided. My final solution looks like this:
@if (Model.MacroParameters["ytVideoLink"] != null) { var fullLink = Model.MacroParameters["ytVideoLink"].ToString(); var youTubeId = fullLink.Split('=').Last();
Split string after a certain character
Hi guys
I am working on a macro for responsive youtube video to use in the grid editor. The idea is that the editor enters the url and the macro does the rest. To get it to work I need to strip the url down to only contain everything after the = in youtube url's.
From this: https://www.youtube.com/watch?v=erLk59H86ww
To this: erLk59H86ww
I thought I could do something like this:
So far my search for some documentation on how to do a simple split has failed. Can anyone point my in the right direction?
Happy New Year to you all :)
/Michael
Hi Michael,
Perhaps you can use the same approach that Jeavon shows in this thread. http://our.umbraco.org/forum/developers/razor/56828-Extract-Youtube-ID-from-url
Hope this helps, or at least gives you inspiration
/Dennis
Hi Dennis
Thank you very much for pointing me in the right direction :) I worked out a solution based on the link you provided. My final solution looks like this:
Thx again and happy New Year to you :)
/Michael
is working on a reply...