我正在尝试匹配两个字符串....我从列表中获取的字符串之一,而另一个字符串由我声明。
set name " HTTP REQUEST = 1\n HTTP REQUEST(SUCCESS) = 0\nSERVER CONN = 1"
set pattern "HTTP REQUEST(SUCCESS)*"
set List [split $name "\n"]
foreach var $List {
set var [lindex $List 1]
#set var2 [string trim $var1 " "]
}
puts $var
if {[regexp $var $pattern match]} {
puts " matched!"
puts $match
} else {
puts " not matched!"
}
答案 0 :(得分:2)
有两个错误:
所以使用
regexp
然后
set pattern {HTTP REQUEST\(SUCCESS\)}
^ ^