I'm trying to capture all the lines between "router bgp" and the last "exit-address-family" using a positive lookabehind but the match only results in capturing up to the first "exit-address-family." How do I make the lookbehind greedy to capture up to the last instance?
import re
config ='''
router bgp 400
bgp log-neighbor-changes
neighbor 10:1::19 remote-as 12000
neighbor 10.1.0.2 remote-as 400
!
address-family ipv4
network 2.0.1.0 mask 255.255.255.0
neighbor 10.1.0.38 activate
exit-address-family
!
address-family ipv6
neighbor 10:1::19 activate
exit-address-family
!
stuff i don't want
more stuff i don't want
'''
rx_bgp_config = re.findall(r'router\s+bgp\s+(\S+)(.*?)(?<=exit-address-family)', config, re.S|re.M)
bgp_config = rx_bgp_config[0]
print(bgp_config)