import sys
import os
import re
import numpy as np
#Tags to remove, sample line: 1:one:2:two:....:122:twentytwo:....:194:ninetyfour:....
r122 = re.compile(':122:(.):')
r194 = re.compile(':194:(.):')
if len(sys.argv) < 2 :
sys.exit('Usage: python %s <file2filter>' % sys.argv[0])
if not os.path.exists(sys.argv[1]):
sys.exit('ERROR: file %s not found!' % sys.argv[1])
with open (sys.argv[1]) as f:
for line in f:
line = re.sub(r':122:(.):', '', str(line))
line = re.sub(r':194:(.):', '', str(line))
print(line,end=" ")
In
1:one:2:two:....:122:twentytwo:....:194:ninetyfour:....
Out
1:one:2:two:....:122:twentytwo:....:194:ninetyfour:....
the tags 122 and 194 are not removed. what am i missing here ?