I’m trying to replace all of the leading spaces in a string with something
var str = ' testing 1 2 3 ',
regex = /^\s*/,
newStr = str.replace(regex, '.');
document.write(newStr)
I want to get a result like:
'.....testing 1 2 3 '
Is there something I’m missing?
Try this:
which prints: