Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Replacing multiple spaces
I’m looking for the best way to replace each occurrence of multiple spaces in a string with a single space.
from
to
Many thanks and Happy Christmas,
Dave
How about something like:
set yourstring ” This is my string “
regsub -all {s+} $yourstring { } newstring
set finalstring [string trim $newstring]
echo $finalstring
I am sure there is a better way, but this should work for you….
That does the business for me.
Thanks,