I am trying to find a way to trim spaces from the start and end of the title string. I was using this, but it doesn\'t seem to be working:
title = title.repl
Here, this should do all that you need
function doSomething(input) {
return input
.replace(/^\s\s*/, '') // Remove Preceding white space
.replace(/\s\s*$/, '') // Remove Trailing white space
.replace(/([\s]+)/g, '-'); // Replace remaining white space with dashes
}
alert(doSomething(" something with some whitespace "));
jQuery.trim(" hello, how are you? ");
:)