1

我的代码现在只用空格替换第一个-,但是 url 中有多个-,我如何用空格替换所有?

window.location.hash.substring(1).replace('-', ' ');
4

1 回答 1

3

尝试:

window.location.hash.substring(1).replace(/-/g, ' ')

g -> 所有实例

于 2012-08-13T01:31:26.483 回答