Validate SoundCloud URL via javascript regex
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:
- mobile version (
m.
after http(s)://) - possible slash at the end
- with or without
SSL/TLS
, so it can behttp
orhttps
- with or without
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\-\.]+