我有2个来自soundcloud的网址,我想在.com /(或).sc /之后获取所有内容,我根本不了解正则表达式,我可以进行javascript匹配/替换,唯一的问题是http vs https
https://soundcloud.com/ilyao/lyao-lj-mtx-and-lj-mtxs-hair
http://snd.sc/1cvgIjv
任何帮助将非常感激。
这就是我所拥有的,不知道如何执行替换的https,或者这是否是解决此问题的最佳方法...
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]
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句