uncolor 351 B

123456789101112
  1. #!/usr/bin/perl
  2. while (<>) {
  3. s/ \e[ #%()*+\-.\/]. |
  4. (?:\e\[|\x9b) [ -?]* [@-~] | # CSI ... Cmd
  5. (?:\e\]|\x9d) .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL)
  6. (?:\e[P^_]|[\x90\x9e\x9f]) .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST
  7. \e.|[\x80-\x9f] //xg;
  8. 1 while s/[^\b][\b]//g; # remove all non-backspace followed by backspace
  9. print;
  10. }