From: Tony De Date: 2008-03-30T09:10:57+09:00 Subject: Re: Regular Expression help Jes炭s Gabriel y Gal叩n wrote: > On Sat, Mar 29, 2008 at 8:16 AM, Tony De wrote: >> >> sourceip = line.scan(/\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b/) >> > /((\d{1,3}\.){3}\d{1,3})(?=\)?\Z)/ >> > => "222.222.222.22" >> > >> > >> > David >> >> David, you rock. I'll give it a try. Those expressions make my head >> hurt. But I've been taking in >> http://www.regular-expressions.info/tutorial.html. It seems to cover a >> lot of foundation and application. Thanks again! > > Another possibility (if I understood correctly): check for the > mandatory ')' in the HELO part, followed by any character (could be > changed by the specific spaces), followed by the numbers and dots for > the IP: > > a = "Received: from mmds-111-19-22-30.twm.ca.internet.net (HELO > ?192.168.1.2?) (222.222.222.22)" > a.match(/\).*?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)[1] > > gives: "222.222.222.22" > > Jesus. Thanks Jesus, I appraciate your imput as well. You guys have been a great deal of help. tonyd -- Posted via http://www.ruby-forum.com/.