开发者

How to replace www. from url without breaking urls like www.someurlwww.com

I have been using .replace("www.", 开发者_运维技巧""); in javascript, but today I was thinking that if an url contains www. in the last part (like someurlwww.com), that will also get replaced. How can I safely cleanup urls protocol+www.?


Try with

.replace(/^http:\/\/www./, "http://")
.replace(/^www./, "")


http://jsfiddle.net/PePS7/7/

this should do the trick

value.replace(/[https*:\\]*www./,""));       
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜