I want to replace part of the URL with JavaScript but stupid regex is giving me headaches. I want to switch from this:
http://website.com/test.html/post/something-else/
to this:
http://website.com/post/something-else/
Any ideas? Thanks!
I want to replace part of the URL with JavaScript but stupid regex is giving me headaches. I want to switch from this:
http://website.com/test.html/post/something-else/
to this:
http://website.com/post/something-else/
Any ideas? Thanks!
Use replace() function
var url = 'http://website.com/test.html/post/something-else/'
url = url.replace('/test.html','')
console.log(url) // "http://website.com/post/something-else/"