拆分列表

时间:2013-01-07 23:44:09

标签: list split tcl

如何拆分下面的列表

\{ X.1.Agg-252 ethernet4/1 island ethernet10/1\} \{ X.1.Agg-252 ethernet4/2 island ethernet10/3\} \{ X.1.Agg-252 ethernet4/3 island ethernet10/5\} 

如下所示:

Element 1  - X.1.Agg-252 ethernet4/1 island ethernet10/1
Element 2 X.1.Agg-252 ethernet4/2 island ethernet10/3
Element 3 X.1.Agg-252 ethernet4/3 island ethernet10/5

2 个答案:

答案 0 :(得分:1)

set a "\{ X.1.Agg-252 ethernet4/1 island ethernet10/1\} \{ X.1.Agg-252 ethernet4/2 island ethernet10/3\} \{ X.1.Agg-252 ethernet4/3 island ethernet10/5\}"
set y [split $a \{\}]
foreach w $y {puts $w}

答案 1 :(得分:0)

var splits = yourString.Replace("{", string.Empty).Split('}');