0

Given that I have the following output :

Loopback1 is up, line protocol is up 
  Hardware is Loopback
  Description: ** NA4-ISIS-MGMT-LOOPBACK1_MPLS **
  Internet address is 84.116.226.27/32
  MTU 1514 bytes, BW 8000000 Kbit, DLY 5000 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation LOOPBACK, loopback not set
  Keepalive set (10 sec)
  Last input 12w3d, output never, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/0 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     0 packets input, 0 bytes, 0 no buffer
     Received 0 broadcasts (0 IP multicasts)
     0 runts, 0 giants, 0 throttles
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
     6 packets output, 456 bytes, 0 underruns
     0 output errors, 0 collisions, 0 interface resets
     0 output buffer failures, 0 output buffers swapped out

How can I match "Loopback1" and not "Loopback" ? In other words, how can I match the interface name only if there is a number next to it, in Tcl ?

1 Answer 1

3

use lookahead

Loopback(?=\d+)

It matches only Loopback in Loopback followed by any number of digits. If you want to match loopback and the number, useLoopback\d+

Sign up to request clarification or add additional context in comments.

3 Comments

thank you Pogo :) i am interested just to find the pattern, not to match the number, so the 1st should be ok, do you mind explaining briefly what "?=" does ?
?= looks ahead for a particular pattern. In /Loopback(?=\d+)/ after a match of Loopback, it looks ahead to find \d+. If \d+ is found, the Loopback is a match, otherwise it isn't.
Pogo, do you know if LookAhead is available in earlier versions than Tcl.v8 ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.