27 May 2009

Regular Expression

^ : Start of line
$ : End of line
[list] : Match a single character in a list.
[^list] : Do not match a single character in a list
. : Any single character
* : Repeat previous regex zero or more times
+ : Repeat previous regex one or more times
? : Repeat previous regex zero or one time
() : Group multiple characters into one regex (normal each character is one regex)

Note: in Cisco regex, grouping is done with \(\)

Example using grouped regex

String = abcdefghi
Match = abc\(...\) .*
Replace =
\1
Result = def
Comment: \1.. \9 are all references to the nth grouped regex

Cisco Reference

No comments:

Post a Comment