Say I have a string like this:
set str "AAA B C DFG 142 56"
Now I want to get a list as follows:
{AAA B C DFG 142 56}
For that I want to use split function, but in that case I get some extra empty lists {}. How I can get the list above?
regexp
could return a list. I would have done this, which is almost as good[split [regsub { {2,}} $string " "] " "]
. The regsub replaces all sequences of spaces of length 2 or more with a single space, then the split splits on that. – Conflict