I have a text file with entries like this:
Interface01 :
adress
192.168.0.1
next-interface:
interface02:
adress
10.123.123.214
next-interface:
interface01 :
adress
172.123.456.123
I'd like to parse it and get only the IP address corresponding to Interface01
I tried may things with python re.finall but couldn't get anything matching
i = open(f, r, encoding='UTF-8')
txt = i.read()
interface = re.findall(r'Interface01 :\s*(.adress*)n',txt,re.DOTALL)
but nothing works.
The expected result is 192.168.0.1.
Interface01\s*:\s*adress\s+(.*). Removere.DOTALL. Use justre.searchto get the first match. See ideone.com/QoE1uF. Can there be more IPs per interface?