Python Forum
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)
Reply


Messages In This Thread
Help with regex please - by mrapple2020 - Apr-06-2019, 08:11 PM
RE: Help with regex please - by mrapple2020 - Apr-07-2019, 12:36 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020