I\'m new to scripting and have been reading about how to use regular expressions.
I want to fetch the complete line matching a pattern.
my ouptut is:
Try
cmd = re.search('^.*\d*% packet loss.*$', ping_result[int(i)], re.M|re.I) print cmd.group()
'^' and '$' match the start and end of a line, respectively. You also don't need the parentheses unless you want to select the packet loss separately.