import sys data = open(r'C:\git\bt411\content\BTL4.RES', 'rb').read() low = data.lower() for name in [b'blhd.bgf', b'blhdbr', b'blh_tor', b'blhd_', b'blhdlarm', b'blhdlule', b'blhdldle', b'blhdlfot']: i = 0 hits = [] while True: i = low.find(name.lower(), i) if i < 0: break hits.append(i) i += 1 print(name.decode(), 'x', len(hits), hits[:6]) # context around blhd.bgf hits i = low.find(b'blhd.bgf') if i >= 0: print(repr(data[i-160:i+40]))