If you have a bunch of files with color escape sequences in them, such as "^[[1m^[[31m", use this snippet to blow them away. Don't forget that the "^[" construct is actually a single 'escape'.

I got tired of trying to get vim to honor the minimal-match modifiers. Another case of perl to the rescue!

%perl -e "while (1) { send_comments(etchorner); }"

while (<INPUT>) { $_ =~ s/\e\[.+?m//g; print; }

Replies are listed 'Best First'.
Re: Kill the color escapes
by chipmunk (Parson) on Jun 07, 2001 at 20:07 UTC
    Since you're only matching a single character at the end, you don't actually need non-greedy matching. You can used a negated character class instead. s/\e\[[^m]+m//g;