#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
package require -exact Gnocl 3.24
set str "\tAbc def ghi klm a. \tYes! "
## reduce multiple spaces within a string but retain \t, trim all external spaces.
# args: str string to modify
# returns: updated string
#
proc removeSpaces { str } {
while 1 {
if { [string first " " $str] == -1 } { break }
set str [string map [list " " " "] $str]
}
return [string trim $str " "]
}
puts >[removeSpaces $str]<
Saturday, November 02, 2024
Remove Stray Repeated Spaces from a String
Subscribe to:
Post Comments (Atom)
-
Given this module some attention today. Added some of the more package wide options to the module and created customised handler for settin...
-
Over the past few programming sessions I've been working on producing a central point, a dashboard, around which it's possible to se...
-
The contents of a GtkTextBuffer can be saved as serialized binary file. Whilst converting such a file to ascii may be problematic if the bu...
No comments:
Post a Comment