removing ASCII escape chars from output

removing ASCII escape chars from output

am 22.12.2007 23:40:40 von SuperGh0d

Hello all,

I have some output that looks like this

$B"+(B[21;32H1700$B"+(B[21;44HTC HUMATHROPE

and I am trying to extract the 1700 and HTC HUMATHROPE. Can someone
point me in the right direction?

thanks!

Re: removing ASCII escape chars from output

am 23.12.2007 09:39:37 von krahnj

On Sat, 22 Dec 2007 14:40:40 -0800 (PST)
SuperGh0d@gmail.com wrote:

> Subject: removing ASCII escape chars from output
>
> I have some output that looks like this
>
> ←[21;32H1700←[21;44HTC HUMATHROPE

There is only one ASCII escape character in there, *the* ASCII escape character. The other characters '[', '2', '1', ';', '3', '2', 'H', etc. are just normal ASCII characters.


> and I am trying to extract the 1700 and HTC HUMATHROPE. Can someone
> point me in the right direction?

You need to remove the ANSI escape sequences:

http://isthe.com/chongo/tech/comp/ansi_escapes.html



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Re: removing ASCII escape chars from output

am 24.12.2007 07:00:11 von DennyTC4

Is the data in the same place everytime? Are the fields static? If so,
count and delte.


On Dec 22, 2:40 pm, SuperG...@gmail.com wrote:
> Hello all,
>
> I have some output that looks like this
>
> $B"+(B[21;32H1700$B"+(B[21;44HTC HUMATHROPE
>
> and I am trying to extract the 1700 and HTC HUMATHROPE. Can someone
> point me in the right direction?
>
> thanks!

Re: removing ASCII escape chars from output

am 24.12.2007 19:33:30 von Benoit Lefebvre

On Dec 23, 3:39 am, "John W. Krahn" wrote:
> On Sat, 22 Dec 2007 14:40:40 -0800 (PST)
>
> SuperG...@gmail.com wrote:
> > Subject: removing ASCII escape chars from output
>
> > I have some output that looks like this
>
> > $B"+(B[21;32H1700$B"+(B[21;44HTC HUMATHROPE
>
> There is only one ASCII escape character in there, *the* ASCII escape character. The other characters '[', '2', '1', ';', '3', '2', 'H', etc. are just normal ASCII characters.
>
> > and I am trying to extract the 1700 and HTC HUMATHROPE. Can someone
> > point me in the right direction?
>
> You need to remove the ANSI escape sequences:
>
> http://isthe.com/chongo/tech/comp/ansi_escapes.html
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order. -- Larry Wall

Because all the ANSI escape sequences are starting with \e[ and ending
with a letter.. Maybe he can do that with a regular expression

for example:
-------------------------
$myText = "$B"+(B[21;32H1700$B"+(B[21;44HTC HUMATHROPE";

$myText =~ s/\e\[[0-9\;]+[A-Za-z]//g;

print $myText. "\n";
-------------------------