heya guys, I'm just looking for a quick way to trim out certain whitespaces from a string. Here is a proc that just takes a seconds input, takes the [duration seconds] value, and trims it down (so weeks becomes w, days becomes d, and so on):
Code: Select all
proc sr:shortdur { t } {
set t [duration $t]
regsub -all -- {years?} $t {y} t
regsub -all -- {weeks?} $t {w} t
regsub -all -- {days?} $t {d} t
regsub -all -- {hours?} $t {h} t
regsub -all -- {minutes?} $t {m} t
regsub -all -- {seconds?} $t {s} t
return $t
}
so a duration of "2 weeks 3 days 14 minutes 36 seconds" then becomes "2 w 3 d 14 m 36 s", but then I'd like to trim the spaces between the number and w,d,m,s so that it becomes: "2w 3d 14m 36s".. So is regsub also the best way to do that, or can you recommend another method?