New to programming with python as my first language.
I'm attempting to create a regex that would match 'lo0.0'
or any other interface that presents in that position from the string below. I need the ip address '192.168.50.5'
to be input as a variable so the regex can be reused dynamically as part of a loop which will ensure that the interface retrieved is the correct outgoing interface for that route.
I've attempted to use positive lookbehind assertions but I haven't had much success in getting the script to take a variable at the start of the regex but within the lookbehind assertion using either dotall
or multiline
.
'\n\ninet.0: 13 destinations, 14 routes (13 active, 0 holddown, 0 hidden)\n+ = Active Route, - = Last Active, * = Both\n\n192.168.50.5/32 *[Direct/0] 1w2d 02:39:35\n > via lo0.0\n'