Need help to filter the proper value from a string,
Here is a display from a ping command:
Expand|Select|Wrap|Line Numbers
- Pinging 10.2.3.6 with 32 bytes of data:
- Request timed out.
- Request timed out.
- Request timed out.
- Ping statistics for 10.2.3.6:
- Packets: Sent = 3, Received = 2, Lost = 1 (66% loss),
Expand|Select|Wrap|Line Numbers
- #IP no. 1: 10.2.3.6
- #IP no. 2: 0
- ['10.20.3.121']
- 66%
and here is part of my script:
Expand|Select|Wrap|Line Numbers
- def print_results():
- for result in results:
- for line in result:
- print line
- def analyse():
- for result in results:
- for line in result:
- mo = re.search("loss" , line)
- if(mo):
- startopenbracket = line.find("(")
- startloss = line.find("loss")
- print line [startopenbracket+1:startloss]