def match(s): return s.find('qxwz_response') > -1 def sub(s): pos = s.find('$') if pos < 0: return '' return s[pos + 1:] def split(s): return list(s.strip().split(',')) if __name__ == '__main__': for line in open('1fps.txt'): if match(line): print(split(sub(line)))