[英]Replace part of URL with JavaScript
我想用JavaScript替换部分URL,但是愚蠢的正则表达式让我头疼。 我要从此切换:
http://website.com/test.html/post/something-else/
对此:
http://website.com/post/something-else/
有任何想法吗? 谢谢!
使用replace()函数
var url = 'http://website.com/test.html/post/something-else/'
url = url.replace('/test.html','')
console.log(url) // "http://website.com/post/something-else/"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.