I'm writing a Python program that logs terminal interaction (similar to the script program), and I'd like to filter out the VT100 escape sequences before writing to disk. I'd like to use a function like this:
def strip_escapes(buf):
escape_regex = re.compile(???) # <--- this is what I'm looking for
return escape_regex.sub('', buf)
What should go in escape_regex
?
VT100 codes are already grouped(mostly) according to similar patterns here:
http://ascii-table.com/ansi-escape-sequences-vt-100.php
I think the simplest approach would be to use some tool like regexbuddy to define a regex for each VT100 codes group.