cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
844
Views
0
Helpful
6
Replies

Compliance Management question

Mehdi Talei
Level 1
Level 1

Hello,

I would like to know the difference between two following commands:

  interface   FastEthernet1

  -   ip address [#.*#]

and

interface   FastEthernet1

  -  [#ip address   .*#]

Thanks,

Mehdi

2 Accepted Solutions

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

The first is a token match regular expression.  It will return true if the config line contains the literal string "ip" followed by the literal string "address" followed by a single token (i.e. a word) that contains zero or more of any character.  As an example, that would match something like:

ip address 10.1.1.1/24

The second pattern is a whole-line regular expression.  It will return true if a config line contains the literal string "ip" followed by the literal string "address" followed by a space, followed by zero or more of any character (spaces included).  For example, that would match:

ip address 10.1.1.1 255.255.255.0

Since the second example is correct, you want the second pattern.  An alternative to both would be:

- ip address [ADDR] [MASK]

Without the '#' the bracketed expressions are variables that stand for any single token.

View solution in original post

No, spaces are not included in the token match pattern.  A token is a word that does not contain any spaces.  To match the mask, you have to use the second pattern or my third option.

View solution in original post

6 Replies 6

Joe Clarke
Cisco Employee
Cisco Employee

The first is a token match regular expression.  It will return true if the config line contains the literal string "ip" followed by the literal string "address" followed by a single token (i.e. a word) that contains zero or more of any character.  As an example, that would match something like:

ip address 10.1.1.1/24

The second pattern is a whole-line regular expression.  It will return true if a config line contains the literal string "ip" followed by the literal string "address" followed by a space, followed by zero or more of any character (spaces included).  For example, that would match:

ip address 10.1.1.1 255.255.255.0

Since the second example is correct, you want the second pattern.  An alternative to both would be:

- ip address [ADDR] [MASK]

Without the '#' the bracketed expressions are variables that stand for any single token.

Thanks Joseph for the reply.

In your answer I see:

"The first is a token  match regular expression.  It will return true if  the config line  contains the literal string "ip" followed by the literal  string  "address" followed by a single token (i.e. a word) that contains  zero or more of any character"

Does "contains zero or more of any character" mean  space also? If yes, the first pattern can contain "ip address 10.1.1.1  255.255.255.0" also, right?

Thanks

No, spaces are not included in the token match pattern.  A token is a word that does not contain any spaces.  To match the mask, you have to use the second pattern or my third option.

Thanks a lot Joseph. So helpful your comments.

Joseph, is there any document or link which explains the dofferent formats of commands?

Thanks

The online help and the examples in compliance management are good starts.  There is also a whitepaper at

http://www.cisco.com/en/US/prod/collateral/netmgtsw/ps6504/ps6528/ps2425/white_paper_c11-529569.html that will be helpful.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: