Reputation: 2594
I am trying to split a Tcl string by TABS (\t).
Please consider the following sampleString
:
I . am -> a . programmer # let "." be spaces and "->" be tabs
If I try to do the following:
set myVar [split $sampleString "\t"]
Tcl will split by spaces as well and not just the tabs.
How can I split only by tabs?
Thanks
Upvotes: 0
Views: 5732
Reputation: 137757
I suspect you're just a little confused as to which output you are looking at.
% set s "I am\ta programmer"
I am a programmer
% split $s
I am a programmer
% split $s "\t"
{I am} {a programmer}
The only difference between the two split
s is that without the optional second argument, the split-set is “all whitespace” (for a reasonable definition of “all”), and neither split
affects the value in the variable as there is no explicit write-back here.
Upvotes: 4