glendeni has asked for the wisdom of the Perl Monks concerning the following question:
I output some text to a terminal by inserting colors via strings ala my $red = "\033[31m"; I would like to sometimes remove that markup for printing to a normal file. But all of the following fail to remove the markup:
What am I missing ?( my $nocolorsline = $line ) =~ s/\033\[[\d;]*[a-zA-Z]//g; ( my $nocolorsline = $line ) =~ s/\e\[[\d;]*[a-zA-Z]//g; ( my $nocolorsline = $line ) =~ s/\Z\[\d;]*[a-zA-Z]//g; ( my $nocolorsline = $line ) =~ s/\x1b\[[\d;]*[a-zA-Z]//g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't remove ANSI markup
by Corion (Patriarch) on Oct 17, 2019 at 08:14 UTC | |
|
Re: Can't remove ANSI markup
by 1nickt (Canon) on Oct 17, 2019 at 02:09 UTC |