muudless
muudless

Reputation: 7532

Replace all '-' in a url

my code now only replaces the first - with space, but there are multiple - in the url, how do I replace all with space?

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

Upvotes: 1

Views: 92

Answers (1)

SciSpear
SciSpear

Reputation: 2008

Try:

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

g -> all instances

Upvotes: 3

Related Questions