我这里有这个代码:
<script type="text/javascript">
var catURL = window.location.pathname;
var catTitle = catURL.split("/");
catTitleNew = catTitle[4].replace("-", " ");
alert(catTitleNew);
//this will alert will convert this-is-my-title to this is-my-title
</script>
我不认为我的替换代码有效,它只替换第一个"-"
如何让它替换所有"-"
?