#!/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...
-
Spent some time today creating some simple howto-tutorials on creating standalone Tcl/Gnocl applications using freewrap. The process is almo...
-
Linux distros have heaps of pre-installed icons ready for use. I recently needed to create a toolbar menu which needed to access a set of un...
No comments:
Post a Comment