in reply to Explanation of a regular expression

work on $x extracts (clumsily) the hexadecimal pairs after the first colon with a space after it, and then precede each pair with an 'x'.

work on $c to remove hex pairs after a colon preceded by hex chars and then remove any new lines.

Then print the result in a formatted way.

My guess is that this code could be replaced by one regexp (2 tops), but without seeing data I can't recommend the best way to approach.

cLive ;-)

  • Comment on Re: Explanation of a regular expression

Replies are listed 'Best First'.
Re: Re: Explanation of a regular expression
by lshatzer (Friar) on Jul 13, 2001 at 23:14 UTC
    This is as close as I got to making this shorter... given the likely data HyperZonk gave.
    #!/usr/bin/perl -p s{^([^:]+):(\s*(?:([\da-f]{2})\s*)+)\s*(.+?)$} {\t"$2",\t\t/* $1: $4 */}x; s/([\da-f]{2}\s)/x$1/g; s/" | "/"/g;
    I got it down to three regexs, the last one as a kludge...
    I am sure if I have spent more time with this, I could have worked it out.