思科的正则表达式" show run interface"命令

时间:2015-01-21 20:12:20

标签: regex

请帮我编写一个正则表达式,它将匹配以“interface bundle-ether”开头并以“!”结尾的所有内容。喜欢这个输出

show run interface bundle-ether1

Tue Jan 20 21:30:28.125 PDT
interface Bundle-Ether1
 description 
 service-policy
 service-policy 
 ipv4 address 
 encapsulation
!

RP/0/RSP0/CPU0:device.name#
show run interface bundle-ether2

Tue Jan 20 21:30:28.394 PDT
interface Bundle-Ether2
 description 
 service-policy 
 service-policy
 ipv4 address 
 encapsulation
!

RP/0/RSP0/CPU0:device.name#
show run interface bundle-ether3

Tue Jan 20 21:30:28.674 PDT
interface Bundle-Ether3
 description
 service-policy
 service-policy
 ipv4 address
 encapsulation
!

2 个答案:

答案 0 :(得分:0)

看起来这个正则表达式真的有魔力:)

interface Bundle\s*(?<text>[^!])+(?:!)?

答案 1 :(得分:-1)

这应该这样做:

interface Bundle-Ether[^!]*!

[^!]*匹配任何非!的字符序列。