替换 window.location.hash url 中的一个字符

Replace a character in window.location.hash url

所以,我有一个锚点,它通过使用 php str_replace 将 space 替换为 - 来调用,现在在 [=18] 内部=] hash 我想撤消这些更改,以便用户搜索没有这些的单词 -。如有任何回应,我们将不胜感激。

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

    console.log(href);

将工作并替换所有“-”而不是一个。

你可以在这里试试 https://codepad.remoteinterview.io/MAZLREUGKE