如何搜索列表中存在的每个字符串。
set Listing [list AB ZS FR WQ GY GT DA PP YT PW]
set strings {ZS RW DA PW}
if { in each $strings no exists in the $listing} {
lappend strNoExitst $get
}
提前致谢!
答案 0 :(得分:2)
set Listing [list AB ZS FR WQ GY GT DA PP YT PW]
set strings {ZS RW DA PW}
set in_list {}
set not_in_list {}
foreach string $strings {
if {$string in $Listing} {
lappend in_list $string
} else {
lappend not_in_list $string
}
}
文档: foreach, if, in (operator), lappend, set