想要从行尾匹配输出到空白
netmgmt@CCC-CC-CCC-RE1> 显示 lldp 邻居本地接口父接口机箱 Id 端口信息系统名称 xe-11/3/0 ae2 00:23:9c:d5:7f:c0 295 BAZ-CPR01-RE1
xe- 10/3/0 ae2 00:23:9c:d5:7f:c0 306 BAZ-CPR01-RE1
xe-8/3/0 ae1 00:23:9c:dd:a7:c0 xe-10/3/0 UKW -CPR02-RE1
xe-9/3/0 ae1 00:23:9c:dd:a7:c0 xe-11/3/0 UKW-CPR02-RE1
我不能使用 left 来字符串正则表达式匹配,因为我可能会在端口信息选项卡中看到空格,所以我试图从头开始匹配。
我相信我在这里使用的 $ 可能与 ${variable} 匹配并导致问题。
我使用了 regex101.com 并且能够使用匹配行中的最后一个单词:((\S+\s+)$)
Value List local_interface (\S+)
Value ae_interface (\S+)
Value lldp_device ((\S+\s+)$)
Start
^Local.*Name -> LLDP
LLDP
^${local_interface}\s+${ae_interface}\s+${lldp_device} -> Record
预期:BAZ-CPR01-RE1 BAZ-CPR01-RE1 UKW-CPR02-RE1 UKW-CPR02-RE1
结果 : []