in reply to Log Parsing using Regex

The above PERL works with the exception that each value in my output contains the "^A".

The language is called "Perl", the interpreter is called "perl". PERL does not exists.

Anyway, if you don't want to capture the ^A, don't put it inside the parenthesis:

if ($line =~ m/\x01 55= (.*?) \x01/x) { ... }

You can get rid of the non-greedy quantifier by using a char class instead:

if ($line =~ m/\x01 55= ([^\x01]*) /x) { ... }

Replies are listed 'Best First'.
Re^2: Log Parsing using Regex
by Anonymous Monk on Jul 09, 2009 at 13:25 UTC
    This is exactly what I was looking for. You also helped me gain a deeper understanding of how the character class works in perl regular expressions.

    Thanks very much!

      Note also that  \cA is an alternate representation of 'control-A' both in and out of a character class.
      >perl -wMstrict -le "my $s = qq{fee\x01fie\x01foe}; $s =~ s{ [\cA] }{--}xmsg; print $s; my $t = qq{biz\cAbaz\cAboz}; $t =~ s{ \x01 }{++}xmsg; print $t; " fee--fie--foe biz++baz++boz