3 ms·
No it isn't. The problem is using regular expressions as the tool for doing it. By feeding the character stream through a proper DEC VT state machine, it's ac
by JdeBP 3y ago
No it isn't. The problem is using regular expressions as the tool for doing it. By feeding the character stream through a proper DEC VT state machine, it's actually fairly trivial.
After all, terminal emulators do exactly this. And it's easy to spot the ones that use state machines instead of regex string matching (which, alas, a few do). The string matchers have had loads of bugs and problems over the years handling unknown but correctly formed control sequences, which the state machine implementations just swallow and ignore with ease.
- junon 3y agoDEC VT is far from the only escape code set. That's more my point. I agree regex isn't the best tool especially for stream processing, but the amount of escape codes out there (and the fact anything can be an escape code...) is what makes it "nearly impossible".