|
|
< Free Open Study > |
|
14-5 Regular Expressions
ConfigurationYou can create regular expressions by forming a template string from any of the following components:
ExamplesA regular expression is used to find the appropriate modem chat scripts matching Hayes- followed by anything. The period matches any character, and the asterisk uses the period to match zero or more times. Therefore, any character or string after Hayes- is matched. line 1 chat-script Hayes-.* A regular expression is used to find the appropriate modem chat script for either usrobotics or hayes. line 2 chat-script usrobotics | hayes A regular expression is used in a BGP AS path list to permit advertisements of a path from the adjacent AS 800. Here, the caret matches the beginning of the AS path string, where 800 is the AS that is adjacent to the local router. The period and asterisk match any other AS path information past the immediately neighboring AS. Also, advertisements of a path through AS 75 are permitted. The underscore characters that surround 75 match any white space or the beginning or end of the AS path string. Refer to Section 7-6 for more information about using regular expressions to match AS paths. ip as-path access-list 10 permit ^800 .* ip as-path access-list 10 permit _75_ A regular expression is used to search through the list of IPX servers and list only server names beginning with HOSP_.
show ipx server regexp HOSP\_.+
A regular expression is used to display only the lines in the running configuration that contain the word VLAN. This might be useful if you need to see a list of the VLAN numbers you have used. show running-config | include VLAN.*_ Suppose you wanted to generate a quick list of interface statistics, consisting of only lines that show the interface number, followed by the line that displays the MAC address. A regular expression is used along with the show interface command to include only the desired information. First, the output lines containing "line protocol" are displayed, because they also begin with the interface type and number. An alternative pattern is given to display output lines that include the word "Hardware," followed by any string, followed by the word "address." This is done to exclude the "Hardware" line for serial interfaces, which have no MAC addresses. show interface | include (line protocol|Hardware.+address) |
|
|
< Free Open Study > |
|