How Do I split the following list into 4 elements using TCL
W.1.Agg-251::ethernet17/24 Z.1.Acc-2::ethernet17/1
I tried as below , But the middle two elements looks to be sticking together ,
set c [split $c ::]
{\ W.1.Agg-251 {} {ethernet17/24 Z.1.Acc-2} {} ethernet17/1}
Update:
The solution provided below does work if I pass the list as it is , but when i pass it as a variable liek below , again I see the middle elements are stuck together .
Like so :
set list2 [lindex $list 0]
o/p==> W.1.Agg-251::ethernet17/24 Z.1.Acc-2::ethernet17/1
set list3 [split [string map {:: :} $list2] ":" ]
o/p==> { W.1.Agg-251} {ethernet17/24 Z.1.Acc-2} ethernet17/1
All you need to do is to replace “::” with a space ” “:
Verify:
Output: