NAME

Regexp::Common::ANSIescape -- regexps for ANSI terminal escapes

SYNOPSIS

use Regexp::Common 'ANSIescape';

if ($str =~ /$RE{ANSIescape}/) {
   ...
}

my $re1 = $RE{ANSIescape}{-only7bit};
my $re2 = $RE{ANSIescape}{-sepstring};

DESCRIPTION

The ANSIescape pattern matches an ANSI terminal escape sequence like

Esc [ 3 0 ; 4 8 m           # CSI sequence
Esc U                       # C1 control
Esc _ APPSTRING Esc \       # C1 with string param

\x9B 3 0 m                  # ditto in 8-bit forms
\x85
\x9F APPSTRING \x9C         

The 8-bit forms use bytes "\x80" through "\x9F". Those bytes are unused in Unicode and the ISO-8859 character sets (Latin-1 etc), so the regexp won't match ordinary characters. The -only7bit option below can omit the 8-bit patterns if you're working with some other charset. The 7-bit patterns are all simply Esc followed by various combinations of printable ASCII "\x20" through "\x7E".

OPTIONS

{-only7bit}
{-only8bit}

Match only the 7-bit forms like "\eE", or only the 8-bit forms like "\x{85}". The default is to match both. The 7-bit forms are the most common.

{-sepstring}

By default the string parameter to APC, DCS, OSC, PM and SOS sequences is included in the match, for example an APC like "\x{9F}Stringarg\x{9C}". With -sepstring the pattern instead matches the "\x{9F}" and the terminator "\x{9C}" individually, leaving the Stringarg unmatched.

{-keep}

With the standard -keep option parens are included to set the following capture variables

$1

The entire escape sequence.

$2

The numeric parameters to a CSI sequence. For example "\e[30;49m" gives $2 as "30;49".

$3

Intermediate characters (if any) and final character of a CSI escape. For example "\e[30m" gives $3 as "m", or with a "+" intermediate byte "\e[30+P" gives $3 as "+P".

SEE ALSO

Regexp::Common

The ANSI standard can be obtained as ECMA-48 at http://www.ecma-international.org/publications/standards/Ecma-048.htm

HOME PAGE

http://www.geocities.com/user42_kevin/perlio-via-escstatus/index.html

LICENSE

Copyright 2008 Kevin Ryde

PerlIO-via-EscStatus is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

PerlIO-via-EscStatus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PerlIO-via-EscStatus. If not, see http://www.gnu.org/licenses/.