Skip to content

Instantly share code, notes, and snippets.

@saitoha
Last active December 10, 2015 16:29
Show Gist options
  • Save saitoha/4461384 to your computer and use it in GitHub Desktop.
Save saitoha/4461384 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
foreach (<stdin>) {
# DCS/OSC/SOS/PM/APC
$_ =~ s/\x1b[P\]X\^_].*(\x07|\x1b\\)//g;
# CSI
$_ =~ s/\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]//g;
# single shift
$_ =~ s/\x1b[\x4e\x4f][\x20\x7e]//g;
# ISO-2022
$_ =~ s/\x1b[\x20-\x2f]*[\x40-\x7e]//g;
# independent ESC
$_ =~ s/\x1b[\x30-\x3f]//g;
# control characters
$_ =~ s/[\x00-\x08\x0e-\x1f\x7f]//g;
print;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment