08-31-2011 04:30 AM
Hello,
I would like to know the difference between two following commands:
interface FastEthernet1
- ip address [#.*#]
and
interface FastEthernet1
- [#ip address .*#]
Thanks,
Mehdi
Solved! Go to Solution.
08-31-2011 06:32 AM
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.
08-31-2011 08:15 AM
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.
08-31-2011 06:32 AM
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.
08-31-2011 08:09 AM
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
08-31-2011 08:15 AM
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.
08-31-2011 08:20 AM
Thanks a lot Joseph. So helpful your comments.
08-31-2011 09:55 AM
Joseph, is there any document or link which explains the dofferent formats of commands?
Thanks
08-31-2011 11:12 PM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide