My output is as below
0.0.0.0/0
unicast-ip4-chain
[@0]: dpo-load-balance: [proto:ip4 index:86 buckets:1 uRPF:102 to:[0:0]]
[0] [@0]: dpo-drop ip4
0.0.0.0/32
unicast-ip4-chain
[@0]: dpo-load-balance: [proto:ip4 index:87 buckets:1 uRPF:88 to:[0:0]]
[0] [@0]: dpo-drop ip4
1.1.1.254/32
unicast-ip4-chain
[@0]: dpo-load-balance: [proto:ip4 index:72 buckets:1 uRPF:41 to:[0:0]]
[0] [@5]: ipv4 via 2.2.2.254 VirtualFuncEthernet0/7/0.1540: mtu:1500 f8c001181ac0fa163e81a6c0810006040800
14.1.1.0/32
unicast-ip4-chain
[@0]: dpo-load-balance: [proto:ip4 index:14 buckets:1 uRPF:111 to:[0:0]]
[0] [@0]: dpo-drop ip4
14.1.1.1/32
unicast-ip4-chain
[@0]: dpo-load-balance: [proto:ip4 index:54 buckets:1 uRPF:61 to:[1228:75011]]
[0] [@5]: ipv4 via 14.1.1.1 VirtualFuncEthernet0/7/0.1540: mtu:1500 f8c001181ac0fa163e81a6c0810006040800
To capture the value 2.2.2.254 from the output I have written regexp as below.
var = 1.1.1.254/32
re.findall(var+r'.*ipv4\s+via\s+(\W+)', x1)
Current output is []