import re if __name__ __main__ re compile with open in txt as for line

1
2
3
4
5
6
7
8
9
import re
if __name__ == '__main__':
r = re.compile(r"[^\s]{7,}")
with open("in.txt", "r") as f:
for line in f:
print ' '.join(map(lambda w: r.sub('', w), line.split()))
f.close()