[英]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.