sed(1) regular expression gurus
Thomas McIntyre
temac at yahoo.com
Mon Jul 14 17:55:37 PDT 2003
Dave wrote:
> This is better than anything I've dreamed up with sed or awk, and
> is really close, but it fails on this:
> by nospam.mc.mpls.visi.com (8.11.6/8.11.6.2) with ESMTP id
3A4E07B03
I know you want to avoid perl, but this kind of problem is it's
sweet spot. The following might be incrementally better (though the
expression to recognize a dotted quad is technically incorrect):
perl -ne '
next unless /^by/;
@f=(split)[1..2];
$_=pop @f;
s/^\D*//g;
s/\D*$//g;
push(@f,$_) if /^(\d{1,3}\.){3}(\d{1,3})$/;
print join(" ", @f)."\n";
'
I'm not fluent enough to translate it but I think awk has all the
required features to do so.
Tom McIntyre
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
More information about the freebsd-questions
mailing list