python - Search for text between 2 strings multiple times on the same line -
i have run little bit of trouble need search text between different strings. pulling url pasted in 1 line.
what searching multiple ips in document (which on same line). full strings in search this:
"ip_str": "0.0.0.0"}
so find text between "ip_str": "
, "}
also possible save of them output text document?
sounds away string splitting:
data = open('input.txt').read() fout = open('output.txt', 'w') parts = data.split('"ip_str": "') part in parts[1:]: part_cleaned = part.split('"}')[0] fout.write(part_cleaned + '\n')
it's quick-and-dirty if write , run once think it's enough. using python's json module cleaner.
Comments
Post a Comment