替换window.location.hash中的字符url [关闭]

问题描述:

so, I have an anchor that is getting called by replacing the space with a - using the php str_replace, now inside of the javascript hash I want to undo these changes so users will search for the words without these -. any response would be appreciated.

所以,我有一个锚点,通过用 - code>替换空格来调用 使用php str_replace code>,现在在javascript哈希内部我要撤消这些更改,以便用户搜索没有这些 - code>的单词。 任何回应都将不胜感激。 p> div>

var href = "a-b-c";
    href = href.replace(/\-/g,"");

    console.log(href);

Will work and replace all "-" instead one.

You can try here https://codepad.remoteinterview.io/MAZLREUGKE