Cisco Reg. Expression
Regular Expression
^ Regular Expression
Use this to look for text at the beginning of a string.
$ Regular Expression:
Use this to look for text at the end of a string
. Regular Expression:
The "." matches any single character.
_ Regular Expression:
This replaces a long regular expression list by matching a comma (,), left brace ({), right brace (}), the beginning of the input string, the end of the input string, or a space.
[ ] Regular Expression:
This matches the characters or a range of characters separated by a hyphen, within left and right square brackets. [02468w] matches for example 0, 4, and w, but not 1, 9, or K
| Regular Expression:
Use the | as a logical or statement. Matches one of the characters or character patterns on either side of the vertical bar. A(B|C)D matches ABD and ACD, but not AD, ABCD, ABBD, or ACCD
\ Regular Expression:
Use this if the following character is not a wildcard, but an actual character you are looking for.
? Regular Expression:
This matches zero or one occurrence of the pattern. (Remember to precede the question mark with Ctrl-V sequence to prevent it from being interpreted as a help command.)ba?b matches bb and bab
+ Regular Expression:
This matches one or more sequences of the character preceding the plus sign. 5+ requires there to be at least one number 5 in the string to be matched
[] Regular Expression:
Nest characters for matching. Separate endpoints of a range with a dash (-). (18)* matches any number of the two-character string 18 ([A-Za-z][0-9])+ matches one or more instances of letter-digit pairs: b8 and W4, as examples
* Regular Expression:
Matches zero or more sequences of the character preceding the asterisk. Also acts as a wildcard for matching any number of characters.0* matches any occurrence of the number 0 including none

Linenum + includes
show all line with contain 255 with the linenumber
	show run linenum | include 255
show all lines begin beginning with 100
	show run linenum | begin 100
Display with | (pipe) Command
	evil-router#sh run | ?
  	append    Append redirected output to URL (URLs supporting append operation only)
  	begin     Begin with the line that matches
  	exclude   Exclude lines that match
  	include   Include lines that match
  	redirect  Redirect output to URL
  	section   Filter a section of output
  	tee       Copy output to URL

Samples:
Sample 1:
ROUTER#show running-config | include ^ (permit|deny) .*object-group
 permit object-group my_allowed_services host 10.10.1.1 host 10.20.1.1
 permit tcp any object-group my_host_group eq 22

Router Crash with Reg Expr.
Some older Router crash , if you enter following Line (it's only a show command)
DO NOT TEST IN YOUR PRODUCTIVE ENVIROMENT!
	ROUTER#show run | b(.*)(\1)+
(c) 2009 by packetlevel.ch / last update: 24.09.2009