标签: javascript
我的代码现在只用空格替换第一个-,但网址中有多个-,如何用空格替换所有?{/ p>
-
window.location.hash.substring(1).replace('-', ' ');
答案 0 :(得分:3)
尝试:
window.location.hash.substring(1).replace(/-/g, ' ')
g - >所有实例