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/", "");
}
function getSoundCloudInfo(url){
var regexp = /^https?:\/\/(soundcloud\.com|snd\.sc)\/(.*)$/;
return url.match(regexp) && url.match(regexp)[2]
}
It is too late, but...
Don't forget about:
m.
after http(s)://)SSL/TLS
, so it can be http
or https
www
So, full regex is:
^(https?:\/\/)?(www.)?(m\.)?soundcloud\.com\/[\w\-\.]+(\/)+[\w\-\.]+/?$
((https:\/\/)|(http:\/\/)|(www.)|(m\.)|(\s))+(soundcloud.com\/)+[a-zA-Z0-9\-\.]+(\/)+[a-zA-Z0-9\-\.]+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With