Cisco – Regular Expression Examples

Great for parsing…

Match a block:

^(line vty (.*))\n( .*\n)*


Match a command within a block:

^(line vty (.*))\n( .*\n)( access-class (.*))\n


Match multiple strings within a command within a block:

^(line vty (.*))\n( .*\n)*( access-class (\S+) (\S+))\n

Match command output from “show cdp neighbor”

^\S*\s*(\S*)\s*(\S*)\s*.*IP Phone.*

regex

Leave a Reply

Your email address will not be published. Required fields are marked *