ansi-regex
ansi-regex copied to clipboard
No support for the newer colon (":") seperated SGR sequences
from wezterm docs:
SGR sequences are of the form CSI DIGITS [; DIGITS ]+ m. That is, any number of semicolon separated numbers, terminated by the m codepoint. There are a handful of slightly more modern sequences that use colon : codepoints to encode additional context.
The colon is also used as an alternative to the semicolon separation method, take a look at this example on wezterm docs.
Some tests done in python to replace every escape sequence to '[ESC]':
Using colons
>>> pattern = "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
>>> re.sub(pattern, '[ESC]', '\x1b[1:2m')
'[ESC]:2m'
Using semicolons
>>> re.sub(pattern, '[ESC]', '\x1b[1;2m')
'[ESC]'