Re: sed(1) regular expression gurus - SOLUTION

2003-07-15 Thread D J Hawkey Jr
First off, thanks to all of you who scratched their heads over this puzzle. All had the right idea to some extent or another. Based in part on the replies, and my own work, here's the final result: FOLDER="$HOME/Mail/spam" NAME_RE="[[:alnum:]_.-]+" ADDY_RE="([0-9]{1,3}\.){3}[0-9]{1,3

Re: Attn: sed(1) regular expression gurus

2003-07-15 Thread Steve Coile
On Mon, 14 Jul 2003, D J Hawkey Jr wrote: >I'm getting really frustrated by a seemingly simple problem. I'm doing >this under FreeBSD 4.5. > >Given these portions of an e-mail's multi-line Received header as tests: > > by some.host.at.a.com (Postfix) with ESMTP id 3A4E07B03 > by some.host.at.a.co

Re: sed(1) regular expression gurus

2003-07-14 Thread Rob
6.789]) id 3A4E07B03 ^^^^^^^ ^ where the hostnames (or IPs) are separated by multiple characters. As you've discovered, this isn't necessarily the best approach - Original Message - From: "D J Hawkey Jr" <[EMAIL PROTECTED]> Subje

Re: sed(1) regular expression gurus

2003-07-14 Thread Thomas McIntyre
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 inc

Re: sed(1) regular expression gurus

2003-07-14 Thread D J Hawkey Jr
On Jul 14, at 11:04 AM, D J Hawkey Jr wrote: > > On Jul 15, at 12:49 AM, Rob wrote: > > > > awk --posix -F'[^0-9A-Za-z.]+' ' > > $1 ~ /by/ { result = $2 > > for (i=3; i<=NF; i++) { > > if ($i ~ /^([0-9]+\.){3}[0-9]+$/) { > > result = result " " $i > > } > > } > > p

Re: sed(1) regular expression gurus

2003-07-14 Thread D J Hawkey Jr
On Jul 15, at 12:49 AM, Rob wrote: > > awk --posix -F'[^0-9A-Za-z.]+' ' > $1 ~ /by/ { result = $2 > for (i=3; i<=NF; i++) { > if ($i ~ /^([0-9]+\.){3}[0-9]+$/) { > result = result " " $i > } > } > print result > }' > > There may be 'neater' ways of doing it, but

Re: sed(1) regular expression gurus

2003-07-14 Thread Rob
work (peculiar to GNU awk). ----- Original Message - From: "D J Hawkey Jr" <[EMAIL PROTECTED]> Subject: Attn: sed(1) regular expression gurus > Hi all. > > I'm getting really frustrated by a seemingly simple problem. I'm doing > this under FreeBSD 4.5. &g

Attn: sed(1) regular expression gurus

2003-07-14 Thread D J Hawkey Jr
Hi all. I'm getting really frustrated by a seemingly simple problem. I'm doing this under FreeBSD 4.5. Given these portions of an e-mail's multi-line Received header as tests: by some.host.at.a.com (Postfix) with ESMTP id 3A4E07B03 by some.host.at.a.com (8.11.6) ESMTP; by some.host.at.a.di