Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Help with regex please
#1
Hello, if possible can someone assist to draft the following regex. I could first retrieve everything after "Outgoing Interface" like I did below. Then match with something like (TenGigE(.......))+ to retrieve the interfaces. I believe there is a better way to do it though with just one regex, but I can't figure it out. Thank you.

#Objective: I need to retrieve "Outgoing Interface" value. In the example below TenGigE0/5/0/1.200, TenGigE0/3/0/1".
string = "[Incoming Interface List  TenGigE0/5/0/1.200 Flags: Outgoing Interface List  TenGigE0/5/0/1.201 Flags: F NS, Up: 01:06:23 blahblah TenGigE0/3/0/1 Flags:"
#I tried:
import re
match = re.findall(r'(?:Outgoing Interface)(.*)', string)
if match:
    #Got all Outgoing Interface output. Now retrieve interfaces:
    print(match)

Quote
#2
I think I found it. Here it is:
raw_int_data = olist_data[1].split('Outgoing Interface List')
    raw_int_out  = raw_int_data[1]
    match = re.findall(r'(TenGig[A-Za-z0-9\/\.]+)', raw_int_out)
    if match:
        print(f'Detected interface...{match}')
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)