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./,""));
精彩评论