用处:正则表达式用来获取回显中想要的字段或某些字段的个数
回显实例
optionalSwitches ![在这里插入图片描述](https://img-blog.csdnimg.cn/396a47e903ec4709bdabf8eea9481d14.png)
一:获取回显中匹配项字段
正则表达式语法
regexp ?optionalSwitches ? patterns ?searchString ?fullMatch subMatch1 ... subMatchn
“-line” :开启行敏感
set buf ["show board-info" -r]
### 正则匹配主框 即 MPU(M)所在机框,并输出主框号:0或1 实例回显中则为0
regexp -line {
MPU\(M\)\s+\S+\s+(\d)} $buf master_mpu_shelf master_shelf
puts master_mpu_shelf:$master_mpu_shelf
puts master_shelf:$master_shelf
输出结果:
master_mpu_shelf:MPU(M) 9900MPUCII 0
master_shelf:0
### 正则匹配备框主主控 即 MPU(M),并输出主主控:T1或T2 实例回显中则为T1
regexp