In javascript, strings are immutable. No string methods change the string they operate on, they all return new strings.
Если требование заменить дефис и обратную косую черту sh пробелом при их первом появлении в URL, добавьте следующий код:
$(document).ready(function() {
//var newTitle = window.location.pathname;
var newTitle = '/fall-2012';
newTitle = newTitle.replace('-', ' ').replace('/', ' ');
$('h1').hide();
$('h1').text(newTitle);
$('h1').show();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1>Old Title</h1>
И если требуется заменить каждое вхождение дефиса и обратного слова sh пробелом в URL, то вам поможет следующее:
$(document).ready(function() {
//var newTitle = window.location.pathname;
var newTitle = '/fall-2012';
newTitle = newTitle.replace(/[-/]/g, ' ');
$('h1').hide();
$('h1').text(newTitle);
$('h1').show();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1>Old Title</h1>