Validate SoundCloud URL via javascript regex
javascript, regex
Solution
function getSoundCloudInfo(url){
var regexp = /^https?:\/\/(soundcloud\.com|snd\.sc)\/(.*)$/;
return url.match(regexp) && url.match(regexp)[2]
}
Problem
I have 2 urls from soundcloud that I would like to get everything after the .com/(or).sc/, I don't understand regex at all, I could do the javascript match/replace, only problem is the http vs https ``` https://soundcloud.com/ilyao/lyao-lj-mtx-and-lj-mtxs-hair http://snd.sc/1cvgIjv ``` Any help would be much appreciated. Here's what I've got, not sure how to do the https of the replace or if this is the best way to approach this... ``` function getSoundCloudInfo(url){ return url.replace("https://soundcloud.com/", "").replace("http://snd.sc/", ""); } ```