Given a line with an unknown number of spaces at the beginning.
I would like to replace each of the spaces with .
ONLY spaces at the beginning of a line should be replaced.
It:
' This is a string with 3 spaces at the beginning';
Must translate to:
' This is a string with 3 spaces at the beginning'
And this:
' This is a string with 5 spaces at the beginning';
Must translate to:
' This is a string with 5 spaces at the beginning'
I am looking for a solution that does not require a loop through the spaces of the string.
source
share