From: Eero Saynatkari Date: 2006-10-03T11:23:58+09:00 Subject: Re: regular expressions --rUztinBX/EQDJOOk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2006.10.03 10:20, MonkeeSage wrote: > Tom Allison wrote: > > I'm only trying to get the one section that matched the Received header. > > I should be able to do with with the statement > > puts line if line =3D~ /Received/ .. line =3D~ /#{config['hostname']}/ > > At least that's what I'm believe I'm being led towards. >=20 > In ruby .. is a range operator. If you want a grouped match, use parens > and a backreference just like perl. >=20 > $stdin.each { |line| > puts $1 if line =3D~ /^Received:(.+?)\s{4,}by #{config['hostname']}/ > # prints " from mail.papa.smurf (mail.papa.smurf [127.0.0.1])" > } And you almost certainly want to Regexp.escape that interpolation. --rUztinBX/EQDJOOk Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFIclJ7Nh7RM4TrhIRAt0/AJ4gLDEwvCVaxKDSuGBusa4oo0lrbQCg2z1z NTvLyPtZ5FkmsKfjdM1wvOA= =BxWl -----END PGP SIGNATURE----- --rUztinBX/EQDJOOk--