我正在使用的代码:
set channel 52/80
if {![ regexp { ([0-9]+)/80 } $channel match cchannel ] } {
puts "Channel regex-ed in [SLVR][SetAffected_channels] is: $cchannelnn"
}
返回错误:无法读取"cchannel":没有这样的变量
我在这里错过了什么吗?
由于多余的空格,您的代码不匹配。
% set channel 52/80
52/80
% regexp { ([0-9]+)/80 } $channel match cchannel
0
% regexp {([0-9]+)/80} $channel match cchannel
1
% set match
52/80
% set cchannel
52
在这种情况下,您也不应该反转regexp
的结果;if
正文脚本似乎适用于模式匹配的情况......