title: Need help on a simple TCL script regarding regexp
body: <p>I'm trying to write a tcl script basically to do following. Based on the syslog below,</p>
  <p>LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/23, changed state to down</p>
  <p>When that log is seen on the router, the script needs to push out a shell command which includes the interface index number, in this case it is 23. I can use regex to scrape the interface in the syslog by doing this below.</p>
  <pre><code>set interface &quot;&quot;
  if {[regexp {.* (GigabitEthernet1/0/[0-9]*)} $syslog_msg match interface]}
  if [catch {cli_exec $cli1(fd) &quot;show port_diag unit 1 port 23&quot;} result] {
  error $result $errorInfo
  }
  }
  </code></pre>
  <p>But how can I use only the interface index number (which is 23) in the command above? Do I need to extract [0-9]* from the regexp and store it as a vairable or somethig like that?</p>