I am trying to parse a log file for a specific string however, the log file has similar strings and when I use my for loop to search the file, it is grabbing the most recent sequence of those characters. Any ideas?
search1 = xyz
search2 = xy
while file as f:
for line in file:
if search2 in line:
print(line)
the log file looks similar to this
asd asda asdaga asdga xy xyz <--- The results I am receiving is the xyz line printing, even though my search variable was xy. I am guessing this is happening because the sequence 'xy' is in 'xyz' but can I search for the exact sequence of a string?
Thanks,