谁能解释之间的区别
expect_out(buffer)
expect_out(0,string)
Run Code Online (Sandbox Code Playgroud)
一般我更喜欢使用expect_out(buffer).
什么是第二个,我们什么时候可以使用它?
有人可以解释一下吗?
您可能需要查看联机帮助页:
我将引用相关部分:
在匹配模式(或eof或full_buffer)时,任何匹配和先前不匹配的输出都保存在变量中
expect_out(buffer).截至9正则表达式匹配字符串保存在变量expect_out(1,string)通过expect_out(9,string).如果在-indices模式之前使用该标志lrange,则10个字符串的起始和结束索引(以适合的形式)存储在变量中expect_out(X,start),expect_out(X,end)其中X是数字,对应于缓冲区中的子字符串位置.0表示与整个模式匹配的字符串,为glob模式和regexp模式生成.例如,如果某个进程已生成输出"abcdefgh\n",则结果为:expect "cd"就好像以下陈述已经执行:
set expect_out(0,string) cd set expect_out(buffer) abcd并
"efgh\n"留在输出缓冲区中.如果进程产生输出"abbbcabkkkka\n",则结果为:expect -indices -re "b(b*).*(k+)"就好像以下陈述已经执行:
set expect_out(0,start) 1 set expect_out(0,end) 10 set expect_out(0,string) bbbcabkkkk set expect_out(1,start) 2 set expect_out(1,end) 3 set expect_out(1,string) bb set expect_out(2,start) 10 set expect_out(2,end) 10 set expect_out(2,string) k set expect_out(buffer) abbbcabkkkk
你可以看到expect_out(0,string)和expect_out(buffer)包含不同的字符串.
| 归档时间: |
|
| 查看次数: |
10501 次 |
| 最近记录: |