Reputation: 55
I'm trying to add a dash between the words Joint Stereo to show like this Joint-Stereo using regsub but just can't get the placement correct. Any help would be appreciated. Here is the snippet
if { $mode == "Joint Stereo" } { regsub {(Joint Stereo)} $mode {\1-} mode putlog "$mode" }
Many thanks in advance.
Upvotes: 0
Views: 101
Reputation: 247042
There are several ways:
set mode [regsub " " $mode "-"] ;# replace the first space
set mode [string map {" " "-"} $mode] ;# replace all spaces
set mode [join $mode "-"] ;# replace all spaces
But Shawn's comment seems most appropriate
Upvotes: 2