TCL-按任意数量的空格将字符串拆分为列表 [英] TCL - split string by arbitrary number of whitespaces to a list
本文介绍了TCL-按任意数量的空格将字符串拆分为列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说我有一个像这样的字符串:
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?
推荐答案
set text "Some arbitrary text which might include \$ or {"
set wordList [regexp -inline -all -- {\S+} $text]
请参见:将字符串拆分为单词.
这篇关于TCL-按任意数量的空格将字符串拆分为列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文